From d420893e601ef18e536bb31c04af570b535bc926 Mon Sep 17 00:00:00 2001 From: Alan Christie Date: Sat, 11 Jan 2025 08:59:23 +0000 Subject: [PATCH] style: Now using pylint in pre-commit --- .pre-commit-config.yaml | 12 +++ behaviour/features/steps/api_utils.py | 10 +- behaviour/features/steps/awx_utils.py | 5 +- behaviour/features/steps/browser_utils.py | 3 + poetry.lock | 111 +++++++++++++++++++--- pyproject.toml | 8 ++ 6 files changed, 133 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1a63d1..2687689 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,3 +52,15 @@ repos: args: - --target-version - py312 + +# pylint +- repo: https://github.com/pycqa/pylint + rev: v3.3.3 + hooks: + - id: pylint + entry: pylint behaviour/features/steps/*.py + args: + - --disable=import-error + - --py-version=3.12 + always_run: true + pass_filenames: false diff --git a/behaviour/features/steps/api_utils.py b/behaviour/features/steps/api_utils.py index 50c380e..1acdcfb 100644 --- a/behaviour/features/steps/api_utils.py +++ b/behaviour/features/steps/api_utils.py @@ -1,5 +1,9 @@ +"""A collection of functions to simplify access to the stack's API, +used primarily to reduce the number of lines in the step file. +""" + import os -from typing import List, Optional +from typing import Optional from urllib.parse import urljoin import requests @@ -79,7 +83,9 @@ def upload_target_experiment( "target_access_string": tas, "file": ( file_name, - open(os.path.join(file_directory, file_name), "rb"), + open( # pylint: disable=consider-using-with + os.path.join(file_directory, file_name), "rb" + ), "application/octet-stream", ), } diff --git a/behaviour/features/steps/awx_utils.py b/behaviour/features/steps/awx_utils.py index 1e27d4b..ac97711 100644 --- a/behaviour/features/steps/awx_utils.py +++ b/behaviour/features/steps/awx_utils.py @@ -44,9 +44,8 @@ def launch_awx_job_template(template, *, extra_vars) -> None: # Put any extra_vars into a local temporary YAML file fp = None if extra_vars: - fp = tempfile.NamedTemporaryFile(mode="w", delete=False) - yaml.dump(extra_vars, fp) - fp.close() + with tempfile.NamedTemporaryFile(mode="w", delete=False) as fp: + yaml.dump(extra_vars, fp) cmd += f" --extra_vars @{fp.name}" diff --git a/behaviour/features/steps/browser_utils.py b/behaviour/features/steps/browser_utils.py index bcd6f76..2e18ee2 100755 --- a/behaviour/features/steps/browser_utils.py +++ b/behaviour/features/steps/browser_utils.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +"""Utilities for interacting with the fragalysis UI that are normally accomplished +via a browser, such as logging in. Underlying logic is handled by playwright. +""" import re from html import unescape diff --git a/poetry.lock b/poetry.lock index 246f3b8..9cf0459 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,16 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "astroid" +version = "3.3.8" +description = "An abstract syntax tree for Python with inference support." +optional = false +python-versions = ">=3.9.0" +files = [ + {file = "astroid-3.3.8-py3-none-any.whl", hash = "sha256:187ccc0c248bfbba564826c26f070494f7bc964fd286b6d9fff4420e55de828c"}, + {file = "astroid-3.3.8.tar.gz", hash = "sha256:a88c7994f914a4ea8572fac479459f4955eeccc877be3f2d959a33273b0cf40b"}, +] + [[package]] name = "awxkit" version = "24.6.1" @@ -93,17 +104,17 @@ uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "boto3" -version = "1.35.94" +version = "1.35.97" description = "The AWS SDK for Python" optional = false python-versions = ">=3.8" files = [ - {file = "boto3-1.35.94-py3-none-any.whl", hash = "sha256:516c514fb447d6f216833d06a0781c003fcf43099a4ca2f5a363a8afe0942070"}, - {file = "boto3-1.35.94.tar.gz", hash = "sha256:5aa606239f0fe0dca0506e0ad6bbe4c589048e7e6c2486cee5ec22b6aa7ec2f8"}, + {file = "boto3-1.35.97-py3-none-any.whl", hash = "sha256:8e49416216a6e3a62c2a0c44fba4dd2852c85472e7b702516605b1363867d220"}, + {file = "boto3-1.35.97.tar.gz", hash = "sha256:7d398f66a11e67777c189d1f58c0a75d9d60f98d0ee51b8817e828930bf19e4e"}, ] [package.dependencies] -botocore = ">=1.35.94,<1.36.0" +botocore = ">=1.35.97,<1.36.0" jmespath = ">=0.7.1,<2.0.0" s3transfer = ">=0.10.0,<0.11.0" @@ -112,13 +123,13 @@ crt = ["botocore[crt] (>=1.21.0,<2.0a0)"] [[package]] name = "botocore" -version = "1.35.94" +version = "1.35.97" description = "Low-level, data-driven core of boto 3." optional = false python-versions = ">=3.8" files = [ - {file = "botocore-1.35.94-py3-none-any.whl", hash = "sha256:d784d944865d8279c79d2301fc09ac28b5221d4e7328fb4e23c642c253b9932c"}, - {file = "botocore-1.35.94.tar.gz", hash = "sha256:2b3309b356541faa4d88bb957dcac1d8004aa44953c0b7d4521a6cc5d3d5d6ba"}, + {file = "botocore-1.35.97-py3-none-any.whl", hash = "sha256:fed4f156b1a9b8ece53738f702ba5851b8c6216b4952de326547f349cc494f14"}, + {file = "botocore-1.35.97.tar.gz", hash = "sha256:88f2fab29192ffe2f2115d5bafbbd823ff4b6eb2774296e03ec8b5b0fe074f61"}, ] [package.dependencies] @@ -303,6 +314,21 @@ files = [ develop = ["backports.shutil-which", "build (>=0.5.1)", "coverage", "invoke (>=1.7.3)", "path (>=13.1.0)", "path.py (>=11.5.0)", "pathlib", "pycmd", "pylint", "pytest (<5.0)", "pytest (>=5.0)", "pytest-html (>=1.19.0)", "ruff", "setuptools", "setuptools-scm", "six (>=1.16.0)", "tox (>=4.23,<4.24)", "twine (>=1.13.0)", "wheel"] testing = ["PyYAML (>=5.4.1)", "pathlib", "pytest (<5.0)", "pytest (>=5.0)", "pytest-html (>=1.19.0)"] +[[package]] +name = "dill" +version = "0.3.9" +description = "serialize all of Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "dill-0.3.9-py3-none-any.whl", hash = "sha256:468dff3b89520b474c0397703366b7b95eebe6303f108adf9b19da1f702be87a"}, + {file = "dill-0.3.9.tar.gz", hash = "sha256:81aa267dddf68cbfe8029c42ca9ec6a4ab3b22371d1c450abc54422577b4512c"}, +] + +[package.extras] +graph = ["objgraph (>=1.7.2)"] +profile = ["gprof2dot (>=2022.7.29)"] + [[package]] name = "distlib" version = "0.3.9" @@ -455,6 +481,20 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] +[[package]] +name = "isort" +version = "5.13.2" +description = "A Python utility / library to sort Python imports." +optional = false +python-versions = ">=3.8.0" +files = [ + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, +] + +[package.extras] +colors = ["colorama (>=0.4.6)"] + [[package]] name = "jmespath" version = "1.0.1" @@ -466,6 +506,17 @@ files = [ {file = "jmespath-1.0.1.tar.gz", hash = "sha256:90261b206d6defd58fdd5e85f478bf633a2901798906be2ad389150c5c60edbe"}, ] +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +optional = false +python-versions = ">=3.6" +files = [ + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, +] + [[package]] name = "mypy-extensions" version = "1.0.0" @@ -627,6 +678,33 @@ typing-extensions = "*" [package.extras] dev = ["black", "build", "flake8", "flake8-black", "isort", "jupyter-console", "mkdocs", "mkdocs-include-markdown-plugin", "mkdocstrings[python]", "pytest", "pytest-asyncio", "pytest-trio", "sphinx", "toml", "tox", "trio", "trio", "trio-typing", "twine", "twisted", "validate-pyproject[all]"] +[[package]] +name = "pylint" +version = "3.3.3" +description = "python code static checker" +optional = false +python-versions = ">=3.9.0" +files = [ + {file = "pylint-3.3.3-py3-none-any.whl", hash = "sha256:26e271a2bc8bce0fc23833805a9076dd9b4d5194e2a02164942cb3cdc37b4183"}, + {file = "pylint-3.3.3.tar.gz", hash = "sha256:07c607523b17e6d16e2ae0d7ef59602e332caa762af64203c24b41c27139f36a"}, +] + +[package.dependencies] +astroid = ">=3.3.8,<=3.4.0-dev0" +colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} +dill = [ + {version = ">=0.3.7", markers = "python_version >= \"3.12\""}, + {version = ">=0.3.6", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, +] +isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" +mccabe = ">=0.6,<0.8" +platformdirs = ">=2.2.0" +tomlkit = ">=0.10.1" + +[package.extras] +spelling = ["pyenchant (>=3.2,<4.0)"] +testutils = ["gitpython (>3)"] + [[package]] name = "pytest" version = "8.3.4" @@ -829,13 +907,13 @@ crt = ["botocore[crt] (>=1.33.2,<2.0a.0)"] [[package]] name = "setuptools" -version = "75.7.0" +version = "75.8.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.9" files = [ - {file = "setuptools-75.7.0-py3-none-any.whl", hash = "sha256:84fb203f278ebcf5cd08f97d3fb96d3fbed4b629d500b29ad60d11e00769b183"}, - {file = "setuptools-75.7.0.tar.gz", hash = "sha256:886ff7b16cd342f1d1defc16fc98c9ce3fde69e087a4e1983d7ab634e5f41f4f"}, + {file = "setuptools-75.8.0-py3-none-any.whl", hash = "sha256:e3982f444617239225d675215d51f6ba05f845d4eec313da4418fdbb56fb27e3"}, + {file = "setuptools-75.8.0.tar.gz", hash = "sha256:c5afc8f407c626b8313a86e10311dd3f661c6cd9c09d4bf8c15c0e11f9f2b0e6"}, ] [package.extras] @@ -869,6 +947,17 @@ files = [ {file = "text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8"}, ] +[[package]] +name = "tomlkit" +version = "0.13.2" +description = "Style preserving TOML library" +optional = false +python-versions = ">=3.8" +files = [ + {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, + {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -920,4 +1009,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "674942d3f9eb6a8619bd64a69604f9758a5f294917f1c254660f77728c7ce02e" +content-hash = "f3debd6f67f1df71dce4a969fd264ebd76309d67ba1240f245f1fa8cae92717e" diff --git a/pyproject.toml b/pyproject.toml index bea38c4..457a992 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,15 @@ requests-toolbelt = "^1.0.0" [tool.poetry.group.dev.dependencies] black = "^24.10.0" +isort = "^5.13.2" pre-commit = "^4.0.1" +pylint = "^3.3.3" + +[tool.pylint.messages_control] +disable = [ + "line-too-long", + "too-many-arguments", +] [build-system] requires = ["poetry-core"]