diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ae6df4fb..efe45087 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: derex/runner/compose_files/openedx_customizations/.* repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.0.0 + rev: v4.0.1 hooks: - id: trailing-whitespace exclude: .bumpversion.cfg @@ -15,7 +15,7 @@ repos: - id: check-yaml - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.1 + rev: 3.9.2 hooks: - id: flake8 args: @@ -25,11 +25,11 @@ repos: :F821,F405,F403,E266" - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.770 + rev: v0.910 hooks: - id: mypy args: - - --ignore-missing-imports + ["--install-types", "--non-interactive", "--ignore-missing-imports"] exclude: "^\ examples/.*|\ docker-definition/derex_django/derex_django/settings/default/.*|\ @@ -37,17 +37,17 @@ repos: $" - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 21.6b0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-isort - rev: v4.3.21 + rev: v5.9.1 hooks: - id: isort - - repo: https://github.com/prettier/prettier - rev: 2.0.5 # Use the sha or tag you want to point at + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.3.1 hooks: - id: prettier exclude: docs/html_templates/layout.html diff --git a/derex/runner/cli/__init__.py b/derex/runner/cli/__init__.py index 2b1208da..1e0ab4d6 100644 --- a/derex/runner/cli/__init__.py +++ b/derex/runner/cli/__init__.py @@ -35,8 +35,7 @@ @click.pass_context @setup_logging_decorator def derex(ctx): - """Derex directs edX: commands to manage an Open edX installation - """ + """Derex directs edX: commands to manage an Open edX installation""" # Optimize --help and bash completion by importing from derex.runner.project import Project @@ -74,17 +73,15 @@ def derex(ctx): @derex.group() @click.pass_context def debug(ctx): - """Debugging utilities - """ + """Debugging utilities""" @derex.command() @click.pass_obj def reset_mailslurper(project): - """Reset the mailslurper database. - """ - from derex.runner.mysql import drop_database + """Reset the mailslurper database.""" from derex.runner.docker_utils import load_dump + from derex.runner.mysql import drop_database drop_database("mailslurper") click.echo("Priming mailslurper database") @@ -147,7 +144,10 @@ def reindex_courses(project, course_ids): @derex.command() @click.option( - "--tty/--no-tty", required=False, default=True, help="Allocate a tty", + "--tty/--no-tty", + required=False, + default=True, + help="Allocate a tty", ) @click.pass_obj @ensure_project @@ -268,10 +268,13 @@ def minio_shell(): @debug.command("print-secret") @click.argument( - "secret", type=str, required=True, + "secret", + type=str, + required=True, ) def print_secret(secret): - from derex.runner.secrets import get_secret, DerexSecrets + from derex.runner.secrets import DerexSecrets + from derex.runner.secrets import get_secret derex_secret = getattr(DerexSecrets, secret, None) if not derex_secret: diff --git a/derex/runner/cli/mongodb.py b/derex/runner/cli/mongodb.py index 1fbc3765..8a950e1c 100644 --- a/derex/runner/cli/mongodb.py +++ b/derex/runner/cli/mongodb.py @@ -28,7 +28,9 @@ def mongodb(context: click.core.Context): "Database", "Tables", "Django users", show_lines=True ) table.add_row( - db["name"], str(db["sizeOnDisk"]), str(db["empty"]), + db["name"], + str(db["sizeOnDisk"]), + str(db["empty"]), ) console.print(table) break @@ -113,7 +115,10 @@ def list_users(): @click.argument("user", type=str) @click.argument("password", type=str) @click.option( - "--role", type=str, multiple=True, help="Role to assign to the user", + "--role", + type=str, + multiple=True, + help="Role to assign to the user", ) def create_user_cmd(user: str, password: str, role: Optional[Tuple]): """Create a mongodb user.""" @@ -166,7 +171,10 @@ def copy_mongodb( @mongodb.command(name="reset-root-password") @click.argument("current_password", type=str, required=False) @click.option( - "--force", is_flag=True, default=False, help="Do not ask for confirmation", + "--force", + is_flag=True, + default=False, + help="Do not ask for confirmation", ) def reset_mongodb_password_cmd(current_password: Optional[str], force: bool): """Reset the mongodb root user password with the one derived diff --git a/derex/runner/cli/mysql.py b/derex/runner/cli/mysql.py index 8a5c2c9b..4462d326 100644 --- a/derex/runner/cli/mysql.py +++ b/derex/runner/cli/mysql.py @@ -224,7 +224,10 @@ def reset_mysql_cmd(context, force): @mysql.command(name="reset-root-password") @click.argument("current_password", type=str, required=True) @click.option( - "--force", is_flag=True, default=False, help="Do not ask for confirmation", + "--force", + is_flag=True, + default=False, + help="Do not ask for confirmation", ) def reset_mysql_password_cmd(current_password: str, force: bool): """Reset the mysql root user password with the one derived from diff --git a/derex/runner/compose_generation.py b/derex/runner/compose_generation.py index 2cfd6d8f..a68c9382 100644 --- a/derex/runner/compose_generation.py +++ b/derex/runner/compose_generation.py @@ -42,8 +42,7 @@ class BaseServices: @staticmethod @hookimpl def ddc_services_options() -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_services_options docstring. - """ + """See derex.runner.plugin_spec.ddc_services_options docstring.""" services_compose_path = generate_ddc_services_compose() options = [ "--project-name", @@ -64,8 +63,7 @@ class BaseProject: @staticmethod @hookimpl def ddc_project_options(project: Project) -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_project_options docstring - """ + """See derex.runner.plugin_spec.ddc_project_options docstring""" project_compose_path = generate_ddc_project_compose(project) options = ["--project-name", project.name, "-f", str(project_compose_path)] return {"options": options, "name": "base-project", "priority": "_begin"} @@ -75,8 +73,7 @@ class LocalServices: @staticmethod @hookimpl def ddc_services_options() -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_services_options docstring. - """ + """See derex.runner.plugin_spec.ddc_services_options docstring.""" local_path = ( Path(os.getenv("DEREX_ETC_PATH", DEREX_ETC_PATH)) / "docker-compose-services.yml" @@ -95,8 +92,7 @@ class LocalProject: @staticmethod @hookimpl def ddc_project_options(project: Project) -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_project_options docstring - """ + """See derex.runner.plugin_spec.ddc_project_options docstring""" options: List[str] = [] if project.local_compose: options = ["-f", str(project.local_compose)] @@ -111,8 +107,7 @@ class LocalProjectRunmode: @staticmethod @hookimpl def ddc_project_options(project: Project) -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_project_options docstring - """ + """See derex.runner.plugin_spec.ddc_project_options docstring""" local_path = project.root / f"docker-compose-{project.runmode.value}.yml" options: List[str] = [] if local_path.is_file(): diff --git a/derex/runner/compose_utils.py b/derex/runner/compose_utils.py index 57cef45d..33919dc2 100644 --- a/derex/runner/compose_utils.py +++ b/derex/runner/compose_utils.py @@ -14,8 +14,7 @@ def run_docker_compose( compose_argv: List[str], dry_run: bool = False, exit_afterwards: bool = False ): - """Run a docker-compose command with the specified arguments. - """ + """Run a docker-compose command with the specified arguments.""" system_argv = sys.argv try: sys.argv = ["docker-compose"] + compose_argv diff --git a/derex/runner/ddc.py b/derex/runner/ddc.py index 9c27987d..1f49ead8 100644 --- a/derex/runner/ddc.py +++ b/derex/runner/ddc.py @@ -91,7 +91,9 @@ def check_docker(): def run_ddc_services( - argv: List[str], dry_run: bool = False, exit_afterwards: bool = False, + argv: List[str], + dry_run: bool = False, + exit_afterwards: bool = False, ): """Run a docker-compose command relative to the system services. Plugin arguments are added to arguments passed in this function sorted by diff --git a/derex/runner/docker_utils.py b/derex/runner/docker_utils.py index 73999a5c..4b59ac25 100644 --- a/derex/runner/docker_utils.py +++ b/derex/runner/docker_utils.py @@ -34,8 +34,7 @@ def is_docker_working() -> bool: - """Check if we can successfully connect to the docker daemon. - """ + """Check if we can successfully connect to the docker daemon.""" try: client.ping() return True @@ -113,8 +112,7 @@ def check_services(services: Iterable[str], max_seconds: int = 1) -> bool: def load_dump(relpath): - """Loads a mysql dump into the derex mysql database. - """ + """Loads a mysql dump into the derex mysql database.""" from derex.runner.mysql import MYSQL_ROOT_PASSWORD dump_path = abspath_from_egg("derex.runner", relpath) @@ -180,8 +178,7 @@ def build_image( def pull_images(image_names: List[str]): - """Pull the given image to the local docker daemon. - """ + """Pull the given image to the local docker daemon.""" # digest = client.api.inspect_distribution(image_name)["Descriptor"]["digest"] for image_name in image_names: print(f"Pulling image {image_name}") @@ -193,8 +190,7 @@ def pull_images(image_names: List[str]): def image_exists(needle: str) -> bool: - """If the given image tag exist in the local docker repository, return True. - """ + """If the given image tag exist in the local docker repository, return True.""" docker_client = docker.APIClient() images = docker_client.images() images.sort(key=lambda el: el["Created"], reverse=True) @@ -207,8 +203,7 @@ def image_exists(needle: str) -> bool: class BuildError(RuntimeError): - """An error occurred while building a docker image - """ + """An error occurred while building a docker image""" def get_running_containers() -> Dict: @@ -240,8 +235,7 @@ def get_exposed_container_names() -> List: def run_minio_shell(command: str = "sh", tty: bool = True): - """Invoke a minio shell - """ + """Invoke a minio shell""" minio_key = get_secret(DerexSecrets.minio) os.system( f"docker run {'-ti ' if tty else ''}--rm --network derex --entrypoint /bin/sh minio/mc -c '" diff --git a/derex/runner/logging_utils.py b/derex/runner/logging_utils.py index 7ed01f0e..0dc9ec7b 100644 --- a/derex/runner/logging_utils.py +++ b/derex/runner/logging_utils.py @@ -25,8 +25,7 @@ def setup_logging(): def setup_logging_decorator(func): - """Decorator to run the setup_logging function before the decorated one. - """ + """Decorator to run the setup_logging function before the decorated one.""" def inner(*args, **kwargs): setup_logging() diff --git a/derex/runner/mysql.py b/derex/runner/mysql.py index ebed9f35..321aba20 100644 --- a/derex/runner/mysql.py +++ b/derex/runner/mysql.py @@ -58,7 +58,7 @@ def get_mysql_client( host: str, user: str, password: str, - port: Optional[int] = 3306, + port: int = 3306, database: Optional[str] = None, **kwargs, ) -> pymysql.cursors.Cursor: diff --git a/derex/runner/plugins.py b/derex/runner/plugins.py index 1a325cb5..d844959d 100644 --- a/derex/runner/plugins.py +++ b/derex/runner/plugins.py @@ -27,7 +27,7 @@ def setup_plugin_manager(): # Used internally by `Registry` for each item in its sorted list. # Provides an easier to read API when editing the code later. # For example, `item.name` is more clear than `item[0]`. -_PriorityItem = namedtuple("PriorityItem", ["name", "priority"]) +_PriorityItem = namedtuple("_PriorityItem", ["name", "priority"]) class Registry(object): @@ -158,7 +158,7 @@ def _sort(self): self._is_sorted = True def add(self, key, value, location): - """ Register a key by location. """ + """Register a key by location.""" if len(self) == 0: # This is the first item. Set priority to 50. priority = 50 diff --git a/derex/runner/project.py b/derex/runner/project.py index 69d45c3e..b49cd09e 100644 --- a/derex/runner/project.py +++ b/derex/runner/project.py @@ -207,8 +207,7 @@ def runmode(self, value: ProjectRunMode): @property def settings(self): - """Name of the module to use as DJANGO_SETTINGS_MODULE - """ + """Name of the module to use as DJANGO_SETTINGS_MODULE""" current_status = self._get_status("settings", "default") return self.get_available_settings()[current_status] @@ -229,8 +228,7 @@ def settings_directory_path(self) -> Path: return DEREX_DJANGO_SETTINGS_PATH def _get_status(self, name: str, default: Optional[str] = None) -> Optional[str]: - """Read value for the desired status from the project directory. - """ + """Read value for the desired status from the project directory.""" filepath = self.private_filepath(name) if filepath.exists(): return filepath.read_text() @@ -265,8 +263,7 @@ def __init__(self, path: Union[Path, str] = None, read_only: bool = False): (self.root / DEREX_RUNNER_PROJECT_DIR).mkdir() def _load(self, path: Union[Path, str] = None): - """Load project configuraton from the given directory. - """ + """Load project configuraton from the given directory.""" if not path: path = os.getcwd() self.root = find_project_root(Path(path)) @@ -493,8 +490,7 @@ def get_openedx_customizations(self) -> dict: def get_requirements_hash(path: Path) -> str: - """Given a directory, return a hash of the contents of the text files it contains. - """ + """Given a directory, return a hash of the contents of the text files it contains.""" hasher = hashlib.sha256() logger.debug( f"Calculating hash for requirements dir {path}; initial (empty) hash is {hasher.hexdigest()}" @@ -537,5 +533,4 @@ def requirements_image_name(self, value): class ProjectNotFound(ValueError): - """No derex project could be found. - """ + """No derex project could be found.""" diff --git a/derex/runner/restore_dump.py.source b/derex/runner/restore_dump.py.source index 3eea7074..e379ddb6 100755 --- a/derex/runner/restore_dump.py.source +++ b/derex/runner/restore_dump.py.source @@ -71,8 +71,7 @@ def run_fixtures(): def execfile_py3(filepath, globals=None, locals=None): - """Taken from https://stackoverflow.com/a/41658338 - """ + """Taken from https://stackoverflow.com/a/41658338""" if globals is None: globals = {} globals.update({"__file__": filepath, "__name__": "__main__"}) diff --git a/derex/runner/secrets.py b/derex/runner/secrets.py index d0b43912..a6d9835d 100644 --- a/derex/runner/secrets.py +++ b/derex/runner/secrets.py @@ -34,8 +34,7 @@ def scrypt_hash_stdlib(main_secret: str, name: str) -> bytes: def scrypt_hash_addon(main_secret: str, name: str) -> bytes: - """ - """ + """ """ from scrypt import scrypt return scrypt.hash(main_secret.encode("utf-8"), name.encode("utf-8"), N=2, r=8, p=1) @@ -97,8 +96,7 @@ def _get_master_secret() -> Optional[str]: def get_secret(secret: DerexSecrets) -> str: - """Derive a secret using the master secret and the provided name. - """ + """Derive a secret using the master secret and the provided name.""" binary_secret = scrypt_hash(MASTER_SECRET, secret.name) # Pad the binary string so that its length is a multiple of 3 # This will make sure its base64 representation is equals-free @@ -107,8 +105,7 @@ def get_secret(secret: DerexSecrets) -> str: class DerexSecretError(ValueError): - """The master secret provided to derex is not valid or could not be found. - """ + """The master secret provided to derex is not valid or could not be found.""" def compute_entropy(s: str) -> float: diff --git a/derex/runner/utils.py b/derex/runner/utils.py index a2e53492..e39abbce 100644 --- a/derex/runner/utils.py +++ b/derex/runner/utils.py @@ -20,8 +20,7 @@ def get_dir_hash( followlinks: bool = False, excluded_extensions: List = [], ) -> str: - """Given a directory return an hash based on its contents - """ + """Given a directory return an hash based on its contents""" if not os.path.isdir(dirname): raise TypeError(f"{dirname} is not a directory.") @@ -65,7 +64,7 @@ def get_dir_hash( def asbool(s: Any) -> bool: - """ Return the boolean value ``True`` if the case-lowered value of string + """Return the boolean value ``True`` if the case-lowered value of string input ``s`` is a `truthy string`. If ``s`` is already one of the boolean values ``True`` or ``False``, return it. Lifted from pyramid.settings. diff --git a/docker-definition/derex_django/derex_django/settings/default/search.py b/docker-definition/derex_django/derex_django/settings/default/search.py index 5dd69331..fad0e4b6 100644 --- a/docker-definition/derex_django/derex_django/settings/default/search.py +++ b/docker-definition/derex_django/derex_django/settings/default/search.py @@ -1,5 +1,9 @@ ELASTIC_SEARCH_CONFIG = [ - {"host": "elasticsearch", "port": 9200, "use_ssl": False,} # noqa: E231 + { + "host": "elasticsearch", + "port": 9200, + "use_ssl": False, + } # noqa: E231 ] SEARCH_ENGINE = "search.elastic.ElasticSearchEngine" SEARCH_INITIALIZER = ( diff --git a/requirements.txt b/requirements.txt index 7cc19ed9..16d6696a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile @@ -19,12 +19,12 @@ cffi==1.14.5 # pynacl chardet==4.0.0 # via requests -click-plugins==1.1.1 - # via derex.runner (setup.py) click==8.0.1 # via # click-plugins # derex.runner (setup.py) +click-plugins==1.1.1 + # via derex.runner (setup.py) colorama==0.4.4 # via rich commonmark==0.9.1 @@ -33,10 +33,10 @@ cryptography==3.4.7 # via paramiko distro==1.5.0 # via docker-compose -docker-compose==1.29.2 - # via derex.runner (setup.py) docker[ssh]==5.0.0 # via docker-compose +docker-compose==1.29.2 + # via derex.runner (setup.py) dockerpty==0.4.1 # via docker-compose docopt==0.6.2 @@ -69,7 +69,7 @@ pynacl==1.4.0 # via paramiko pyrsistent==0.17.3 # via jsonschema -python-dotenv==0.17.1 +python-dotenv==0.18.0 # via docker-compose pyyaml==5.4.1 # via @@ -79,7 +79,7 @@ requests==2.25.1 # via # docker # docker-compose -rich==10.3.0 +rich==10.4.0 # via derex.runner (setup.py) six==1.16.0 # via diff --git a/requirements_dev.in b/requirements_dev.in index 1a7ab7ea..a00972f8 100644 --- a/requirements_dev.in +++ b/requirements_dev.in @@ -15,6 +15,7 @@ pytest-cov pytest-mock>=v3.1.0 pytest-runner pyyaml +scrypt requests tox twine diff --git a/requirements_dev.txt b/requirements_dev.txt index 8813322a..93a28e53 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile requirements_dev.in @@ -12,7 +12,7 @@ appdirs==1.4.4 # -r requirements.txt # black # virtualenv -astroid==2.5.8 +astroid==2.6.0 # via sphinx-autoapi attrs==21.2.0 # via @@ -54,10 +54,6 @@ chardet==4.0.0 # -c requirements.txt # -r requirements.txt # requests -click-plugins==1.1.1 - # via - # -c requirements.txt - # -r requirements.txt click==8.0.1 # via # -c requirements.txt @@ -65,6 +61,10 @@ click==8.0.1 # black # click-plugins # pip-tools +click-plugins==1.1.1 + # via + # -c requirements.txt + # -r requirements.txt colorama==0.4.4 # via # -c requirements.txt @@ -93,15 +93,15 @@ distro==1.5.0 # -c requirements.txt # -r requirements.txt # docker-compose -docker-compose==1.29.2 +docker[ssh]==5.0.0 # via # -c requirements.txt # -r requirements.txt -docker[ssh]==5.0.0 + # docker-compose +docker-compose==1.29.2 # via # -c requirements.txt # -r requirements.txt - # docker-compose dockerpty==0.4.1 # via # -c requirements.txt @@ -120,10 +120,10 @@ filelock==3.0.12 # via # tox # virtualenv -flake8-import-order==0.18.1 - # via -r requirements_dev.in flake8==3.9.2 # via -r requirements_dev.in +flake8-import-order==0.18.1 + # via -r requirements_dev.in identify==2.2.10 # via pre-commit idna==2.10 @@ -141,7 +141,7 @@ importlib-metadata==4.5.0 # twine iniconfig==1.1.1 # via pytest -isort==5.8.0 +isort==5.9.1 # via -r requirements_dev.in jeepney==0.6.0 # via @@ -169,12 +169,12 @@ markupsafe==2.0.1 # jinja2 mccabe==0.6.1 # via flake8 +mypy==0.761 + # via -r requirements_dev.in mypy-extensions==0.4.3 # via # black # mypy -mypy==0.761 - # via -r requirements_dev.in nodeenv==1.6.0 # via pre-commit packaging==20.9 @@ -192,7 +192,7 @@ pathspec==0.8.1 # via black pep517==0.10.0 # via pip-tools -pip-tools==6.1.0 +pip-tools==6.2.0 # via -r requirements_dev.in pkginfo==1.7.0 # via twine @@ -248,6 +248,12 @@ pyrsistent==0.17.3 # -c requirements.txt # -r requirements.txt # jsonschema +pytest==6.2.4 + # via + # -r requirements_dev.in + # pytest-black + # pytest-cov + # pytest-mock git+https://github.com/Abstract-Tech/pytest-black.git#egg=pytest-black # via -r requirements_dev.in pytest-cov==2.12.1 @@ -256,13 +262,7 @@ pytest-mock==3.6.1 # via -r requirements_dev.in pytest-runner==5.3.1 # via -r requirements_dev.in -pytest==6.2.4 - # via - # -r requirements_dev.in - # pytest-black - # pytest-cov - # pytest-mock -python-dotenv==0.17.1 +python-dotenv==0.18.0 # via # -c requirements.txt # -r requirements.txt @@ -281,8 +281,6 @@ readme-renderer==29.0 # via twine regex==2021.4.4 # via black -requests-toolbelt==0.9.1 - # via twine requests==2.25.1 # via # -c requirements.txt @@ -293,12 +291,16 @@ requests==2.25.1 # requests-toolbelt # sphinx # twine +requests-toolbelt==0.9.1 + # via twine rfc3986==1.5.0 # via twine -rich==10.3.0 +rich==10.4.0 # via # -c requirements.txt # -r requirements.txt +scrypt==0.8.18 + # via -r requirements_dev.in secretstorage==3.3.1 # via keyring six==1.16.0 @@ -316,15 +318,15 @@ six==1.16.0 # websocket-client snowballstemmer==2.1.0 # via sphinx -sphinx-autoapi==1.8.1 - # via -r requirements_doc.in -sphinx-press-theme==0.7.3 - # via -r requirements_doc.in sphinx==4.0.2 # via # -r requirements_doc.in # sphinx-autoapi # sphinx-press-theme +sphinx-autoapi==1.8.1 + # via -r requirements_doc.in +sphinx-press-theme==0.7.3 + # via -r requirements_doc.in sphinxcontrib-applehelp==1.0.2 # via sphinx sphinxcontrib-devhelp==1.0.2 @@ -353,7 +355,7 @@ toml==0.10.2 # tox tox==3.23.1 # via -r requirements_dev.in -tqdm==4.61.0 +tqdm==4.61.1 # via twine twine==3.4.1 # via -r requirements_dev.in @@ -383,7 +385,9 @@ websocket-client==0.59.0 # docker # docker-compose wheel==0.36.2 - # via -r requirements_dev.in + # via + # -r requirements_dev.in + # pip-tools wrapt==1.12.1 # via astroid zipp==3.4.1 diff --git a/requirements_doc.txt b/requirements_doc.txt index 8bae20df..f9dd4ff2 100644 --- a/requirements_doc.txt +++ b/requirements_doc.txt @@ -1,12 +1,12 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.8 # To update, run: # # pip-compile requirements_doc.in # alabaster==0.7.12 # via sphinx -astroid==2.5.8 +astroid==2.6.0 # via sphinx-autoapi babel==2.9.1 # via sphinx @@ -57,15 +57,15 @@ requests==2.25.1 # sphinx snowballstemmer==2.1.0 # via sphinx -sphinx-autoapi==1.8.1 - # via -r requirements_doc.in -sphinx-press-theme==0.7.3 - # via -r requirements_doc.in sphinx==4.0.2 # via # -r requirements_doc.in # sphinx-autoapi # sphinx-press-theme +sphinx-autoapi==1.8.1 + # via -r requirements_doc.in +sphinx-press-theme==0.7.3 + # via -r requirements_doc.in sphinxcontrib-applehelp==1.0.2 # via sphinx sphinxcontrib-devhelp==1.0.2 diff --git a/setup.py b/setup.py index 80cd9d9d..c08fa909 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup_requirements = ["setuptools"] -test_requirements = ["pytest", "pytest-mock>=v3.1.0"] +test_requirements = ["pytest", "pytest-mock>=v3.1.0", "scrypt"] extras_requirements = { "test": test_requirements, diff --git a/tests/test_compose_utils.py b/tests/test_compose_utils.py index a4edae1d..e3d229c7 100644 --- a/tests/test_compose_utils.py +++ b/tests/test_compose_utils.py @@ -4,8 +4,8 @@ @pytest.mark.slowtest def test_run_django_script(minimal_project): with minimal_project: - from derex.runner.project import Project from derex.runner.ddc import run_django_script + from derex.runner.project import Project result = run_django_script( Project(), "import json; print(json.dumps(dict(foo='bar', one=1)))" diff --git a/tests/test_mongodb.py b/tests/test_mongodb.py index b2470d83..c1203500 100644 --- a/tests/test_mongodb.py +++ b/tests/test_mongodb.py @@ -38,9 +38,10 @@ def cleanup_mongodb(start_mongodb): def test_derex_mongodb(start_mongodb): - from derex.runner.mongodb import list_databases from derex.runner.cli.mongodb import copy_mongodb from derex.runner.cli.mongodb import drop_mongodb + from derex.runner.mongodb import list_databases + import derex.runner.mongodb reload(derex.runner.mongodb) @@ -65,11 +66,9 @@ def test_derex_mongodb(start_mongodb): def test_derex_mongodb_reset_password(mocker, start_mongodb): - from derex.runner.cli.mongodb import ( - create_user_cmd, - reset_mongodb_password_cmd, - shell, - ) + from derex.runner.cli.mongodb import create_user_cmd + from derex.runner.cli.mongodb import reset_mongodb_password_cmd + from derex.runner.cli.mongodb import shell assert_result_ok( runner.invoke(create_user_cmd, [DEREX_TEST_USER, "secret", "--role=root"]) diff --git a/tests/test_mysql.py b/tests/test_mysql.py index e8ef5bad..99e2be80 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -43,7 +43,7 @@ def cleanup_mysql(start_mysql): @pytest.mark.slowtest def test_derex_mysql(start_mysql): - """Test the `derex mysql copy` cli command """ + """Test the `derex mysql copy` cli command""" from derex.runner.cli.mysql import copy_database_cmd from derex.runner.cli.mysql import create_database_cmd from derex.runner.cli.mysql import drop_database_cmd @@ -92,8 +92,10 @@ def test_derex_mysql_reset(start_mysql, mocker, minimal_project): @pytest.mark.slowtest def test_derex_mysql_reset_password(start_mysql, mocker): - """Test the `derex mysql copy` cli command """ - from derex.runner.cli.mysql import create_user_cmd, reset_mysql_password_cmd, shell + """Test the `derex mysql copy` cli command""" + from derex.runner.cli.mysql import create_user_cmd + from derex.runner.cli.mysql import reset_mysql_password_cmd + from derex.runner.cli.mysql import shell for host in ["localhost", "%"]: runner.invoke(create_user_cmd, [DEREX_TEST_USER, "secret", host]) diff --git a/tests/test_project.py b/tests/test_project.py index 789acd06..fd634756 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -77,9 +77,10 @@ def test_ddc_project_addition(minimal_project, mocker, capsys): class CustomAdditional: @staticmethod @hookimpl - def ddc_project_options(project: Project,) -> Dict[str, Union[str, List[str]]]: - """See derex.runner.plugin_spec.ddc_project_options docstring - """ + def ddc_project_options( + project: Project, + ) -> Dict[str, Union[str, List[str]]]: + """See derex.runner.plugin_spec.ddc_project_options docstring""" return { "options": ["custom-additional"], "name": "custom", diff --git a/tests/test_secrets.py b/tests/test_secrets.py index bfadec3c..150dd55d 100644 --- a/tests/test_secrets.py +++ b/tests/test_secrets.py @@ -28,8 +28,7 @@ def test_master_secret_default_filename(mocker): def test_master_secret_default_filename_not_readable(mocker): - """If the file exists but is not readable we should log an error. - """ + """If the file exists but is not readable we should log an error.""" from derex.runner.secrets import _get_master_secret mocker.patch("derex.runner.secrets.os.access", return_value=False) @@ -67,8 +66,8 @@ def test_master_secret_custom_filename(tmp_path, monkeypatch): def test_derived_secret(): - from derex.runner.secrets import get_secret from derex.runner.secrets import compute_entropy + from derex.runner.secrets import get_secret foo_secret = get_secret(FooSecrets.foo) # The same name should always yield the same secrets @@ -102,8 +101,8 @@ def test_derived_secret_no_scrypt_available(no_scrypt): only_one_scrypt_implementations, reason="We don't have both openssl>=1.1 and scrypt" ) def test_derived_secret_no_scrypt_same_result_as_with_scrypt(): - from derex.runner.secrets import scrypt_hash_stdlib from derex.runner.secrets import scrypt_hash_addon + from derex.runner.secrets import scrypt_hash_stdlib TEST_CASES = [("aaa", "bbb"), ("The master secret", "the service")] for a, b in TEST_CASES: diff --git a/tests/test_utils.py b/tests/test_utils.py index 8440b46d..9122100b 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- def test_asbool(): - """It's lifted from pyramid.settings, but testing it here won't harm. - """ + """It's lifted from pyramid.settings, but testing it here won't harm.""" from derex.runner.utils import asbool assert asbool(True) is True