mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 02:44:21 +02:00
Fix mypy joinpath errors (#9871)
* Fix mypy joinpath errors * update changelog
This commit is contained in:
@@ -257,6 +257,6 @@ def find_ssl_apache_conf(prefix: str) -> str:
|
|||||||
"""
|
"""
|
||||||
file_manager = ExitStack()
|
file_manager = ExitStack()
|
||||||
atexit.register(file_manager.close)
|
atexit.register(file_manager.close)
|
||||||
ref = importlib_resources.files("certbot_apache").joinpath(
|
ref = (importlib_resources.files("certbot_apache").joinpath("_internal")
|
||||||
"_internal", "tls_configs", "{0}-options-ssl-apache.conf".format(prefix))
|
.joinpath("tls_configs").joinpath("{0}-options-ssl-apache.conf".format(prefix)))
|
||||||
return str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
return str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
||||||
|
|||||||
@@ -32,13 +32,15 @@ def construct_nginx_config(nginx_root: str, nginx_webroot: str, http_port: int,
|
|||||||
if not key_path:
|
if not key_path:
|
||||||
file_manager = ExitStack()
|
file_manager = ExitStack()
|
||||||
atexit.register(file_manager.close)
|
atexit.register(file_manager.close)
|
||||||
ref = importlib_resources.files('certbot_integration_tests').joinpath('assets', 'key.pem')
|
ref = (importlib_resources.files('certbot_integration_tests').joinpath('assets')
|
||||||
|
.joinpath('key.pem'))
|
||||||
key_path = str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
key_path = str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
||||||
|
|
||||||
if not cert_path:
|
if not cert_path:
|
||||||
file_manager = ExitStack()
|
file_manager = ExitStack()
|
||||||
atexit.register(file_manager.close)
|
atexit.register(file_manager.close)
|
||||||
ref = importlib_resources.files('certbot_integration_tests').joinpath('assets', 'cert.pem')
|
ref = (importlib_resources.files('certbot_integration_tests').joinpath('assets')
|
||||||
|
.joinpath('cert.pem'))
|
||||||
cert_path = str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
cert_path = str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
||||||
|
|
||||||
return '''\
|
return '''\
|
||||||
|
|||||||
@@ -48,9 +48,8 @@ class IntegrationTestsContext(certbot_context.IntegrationTestsContext):
|
|||||||
:yields: Path to credentials file
|
:yields: Path to credentials file
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
src_ref_file = importlib_resources.files('certbot_integration_tests').joinpath(
|
src_ref_file = (importlib_resources.files('certbot_integration_tests').joinpath('assets')
|
||||||
'assets', 'bind-config', f'rfc2136-credentials-{label}.ini.tpl'
|
.joinpath('bind-config').joinpath(f'rfc2136-credentials-{label}.ini.tpl'))
|
||||||
)
|
|
||||||
with importlib_resources.as_file(src_ref_file) as src_file:
|
with importlib_resources.as_file(src_ref_file) as src_file:
|
||||||
with open(src_file, 'r') as f:
|
with open(src_file, 'r') as f:
|
||||||
contents = f.read().format(
|
contents = f.read().format(
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ def generate_test_file_hooks(config_dir: str, hook_probe: str) -> None:
|
|||||||
"""
|
"""
|
||||||
file_manager = contextlib.ExitStack()
|
file_manager = contextlib.ExitStack()
|
||||||
atexit.register(file_manager.close)
|
atexit.register(file_manager.close)
|
||||||
hook_path_ref = importlib_resources.files('certbot_integration_tests').joinpath(
|
hook_path_ref = (importlib_resources.files('certbot_integration_tests').joinpath('assets')
|
||||||
'assets', 'hook.py')
|
.joinpath('hook.py'))
|
||||||
hook_path = str(file_manager.enter_context(importlib_resources.as_file(hook_path_ref)))
|
hook_path = str(file_manager.enter_context(importlib_resources.as_file(hook_path_ref)))
|
||||||
|
|
||||||
for hook_dir in list_renewal_hooks_dirs(config_dir):
|
for hook_dir in list_renewal_hooks_dirs(config_dir):
|
||||||
@@ -262,9 +262,8 @@ def load_sample_data_path(workspace: str) -> str:
|
|||||||
:returns: the path to the loaded sample data directory
|
:returns: the path to the loaded sample data directory
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
original_ref = importlib_resources.files('certbot_integration_tests').joinpath(
|
original_ref = (importlib_resources.files('certbot_integration_tests').joinpath('assets')
|
||||||
'assets', 'sample-config'
|
.joinpath('sample-config'))
|
||||||
)
|
|
||||||
with importlib_resources.as_file(original_ref) as original:
|
with importlib_resources.as_file(original_ref) as original:
|
||||||
copied = os.path.join(workspace, 'sample-config')
|
copied = os.path.join(workspace, 'sample-config')
|
||||||
shutil.copytree(original, copied, symlinks=True)
|
shutil.copytree(original, copied, symlinks=True)
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ class NginxConfigurator(common.Configurator):
|
|||||||
|
|
||||||
file_manager = ExitStack()
|
file_manager = ExitStack()
|
||||||
atexit.register(file_manager.close)
|
atexit.register(file_manager.close)
|
||||||
ref = importlib_resources.files("certbot_nginx").joinpath(
|
ref = (importlib_resources.files("certbot_nginx").joinpath("_internal")
|
||||||
"_internal", "tls_configs", config_filename)
|
.joinpath("tls_configs").joinpath(config_filename))
|
||||||
|
|
||||||
return str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
return str(file_manager.enter_context(importlib_resources.as_file(ref)))
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ Certbot adheres to [Semantic Versioning](https://semver.org/).
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
*
|
* Updates `joinpath` syntax to only use one addition per call, because the multiple inputs
|
||||||
|
version was causing mypy errors on Python 3.10.
|
||||||
|
|
||||||
More details about these changes can be found on our GitHub repo.
|
More details about these changes can be found on our GitHub repo.
|
||||||
|
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ def dir_setup(test_dir: str, pkg: str) -> Tuple[str, str, str]: # pragma: no co
|
|||||||
filesystem.chmod(config_dir, constants.CONFIG_DIRS_MODE)
|
filesystem.chmod(config_dir, constants.CONFIG_DIRS_MODE)
|
||||||
filesystem.chmod(work_dir, constants.CONFIG_DIRS_MODE)
|
filesystem.chmod(work_dir, constants.CONFIG_DIRS_MODE)
|
||||||
|
|
||||||
test_dir_ref = importlib_resources.files(pkg).joinpath("testdata", test_dir)
|
test_dir_ref = importlib_resources.files(pkg).joinpath("testdata").joinpath(test_dir)
|
||||||
with importlib_resources.as_file(test_dir_ref) as path:
|
with importlib_resources.as_file(test_dir_ref) as path:
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
path, os.path.join(temp_dir, test_dir), symlinks=True)
|
path, os.path.join(temp_dir, test_dir), symlinks=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user