From 3893c6933e6ce5a47981cb563349c0d055cb08eb Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Wed, 16 Nov 2022 14:40:50 -0800 Subject: [PATCH] chore: run lint tests on CI --- .github/workflows/python-package.yml | 1 + .pre-commit-config.yaml | 8 ++++---- .pylintrc | 10 ++-------- dev-requirements.txt | 8 ++++++++ setup.cfg | 1 + src/preset_cli/auth/lib.py | 1 + src/preset_cli/auth/main.py | 2 +- src/preset_cli/auth/password.py | 2 +- tests/api/clients/superset_test.py | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 61de833d..ef1181a5 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -30,4 +30,5 @@ jobs: python -m pip install -r dev-requirements.txt - name: Test with pytest run: | + pre-commit run --all-files pytest --cov-fail-under=100 --cov=src/preset_cli -vv tests/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fe72142..4fcbcee7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: '^docs/conf.py' repos: -- repo: git://github.com/pre-commit/pre-commit-hooks +- repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: check-added-large-files @@ -34,7 +34,7 @@ repos: - id: isort - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.10.0 hooks: - id: black language_version: python3 @@ -46,7 +46,7 @@ repos: # - id: blacken-docs # additional_dependencies: [black] -- repo: https://gitlab.com/pycqa/flake8 +- repo: https://github.com/PyCQA/flake8 rev: 3.9.2 hooks: - id: flake8 @@ -74,7 +74,7 @@ repos: # - id: reorder-python-imports # args: [--application-directories=.:src] - repo: https://github.com/hadialqattan/pycln - rev: v2.1.1 # Possible releases: https://github.com/hadialqattan/pycln/tags + rev: v2.1.2 # Possible releases: https://github.com/hadialqattan/pycln/tags hooks: - id: pycln args: [--config=pyproject.toml] diff --git a/.pylintrc b/.pylintrc index b1c2dc98..08a67d7a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,12 +1,6 @@ [MESSAGES CONTROL] -disable = - duplicate-code - use-implicit-booleaness-not-comparison - fixme +disable = duplicate-code,use-implicit-booleaness-not-comparison,fixme [MASTER] ignore=templates,docs -disable = - duplicate-code - use-implicit-booleaness-not-comparison - fixme +disable = duplicate-code,use-implicit-booleaness-not-comparison,fixme diff --git a/dev-requirements.txt b/dev-requirements.txt index 7db6a263..8e208ce1 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -8,6 +8,7 @@ aiohttp==3.8.3 aiosignal==1.2.0 appdirs==1.4.4 +astroid==2.12.12 async-timeout==4.0.2 attrs==22.1.0 backoff==2.2.1 @@ -21,6 +22,7 @@ codespell==2.1.0 commonmark==0.9.1 coverage[toml]==6.4.3 cython==0.29.32 +dill==0.3.6 distlib==0.3.5 filelock==3.8.0 freezegun==1.2.2 @@ -29,9 +31,12 @@ greenlet==1.1.3.post0 identify==2.5.3 idna==3.3 iniconfig==1.1.1 +isort==5.10.1 jinja2==3.1.2 +lazy-object-proxy==1.8.0 markupsafe==2.1.1 marshmallow==3.17.0 +mccabe==0.7.0 multidict==6.0.2 nodeenv==1.7.0 numpy==1.23.1 @@ -47,6 +52,7 @@ prompt-toolkit==3.0.30 py==1.11.0 pyfakefs==4.6.3 pygments==2.12.0 +pylint==2.15.5 pyparsing==3.0.9 pytest==7.1.2 pytest-cov==3.0.0 @@ -65,12 +71,14 @@ sqlparse==0.4.2 tabulate==0.8.10 toml==0.10.2 tomli==2.0.1 +tomlkit==0.11.6 typing-extensions==4.3.0 urllib3==1.26.9 virtualenv==20.16.3 wcwidth==0.2.5 websockets==10.3 wheel==0.37.1 +wrapt==1.14.1 yarl==1.8.1 # The following packages are considered to be unsafe in a requirements file: diff --git a/setup.cfg b/setup.cfg index 6c9eaae4..98a60939 100644 --- a/setup.cfg +++ b/setup.cfg @@ -100,6 +100,7 @@ testing = codespell pre-commit pip-tools>=6.6.0 + pylint>=2.11.1 [options.entry_points] # Add here console scripts like: diff --git a/src/preset_cli/auth/lib.py b/src/preset_cli/auth/lib.py index 8507d14e..35823329 100644 --- a/src/preset_cli/auth/lib.py +++ b/src/preset_cli/auth/lib.py @@ -24,6 +24,7 @@ def get_access_token(baseurl: Union[str, URL], api_token: str, api_secret: str) baseurl / "v1/auth/", json={"name": api_token, "secret": api_secret}, headers={"Content-Type": "application/json"}, + timeout=60, ) response.raise_for_status() payload = response.json() diff --git a/src/preset_cli/auth/main.py b/src/preset_cli/auth/main.py index 552c12a4..482e7972 100644 --- a/src/preset_cli/auth/main.py +++ b/src/preset_cli/auth/main.py @@ -16,7 +16,7 @@ def __init__(self): self.session = Session() self.session.hooks["response"].append(self.reauth) - def get_headers(self) -> Dict[str, str]: # pylint: disable=no-self-use + def get_headers(self) -> Dict[str, str]: """ Return headers for auth. """ diff --git a/src/preset_cli/auth/password.py b/src/preset_cli/auth/password.py index 27ef2740..274ddc37 100644 --- a/src/preset_cli/auth/password.py +++ b/src/preset_cli/auth/password.py @@ -24,7 +24,7 @@ def __init__(self, baseurl: URL, username: str, password: Optional[str] = None): self.password = password self.auth() - def get_headers(self) -> Dict[str, str]: # pylint: disable=no-self-use + def get_headers(self) -> Dict[str, str]: return {"X-CSRFToken": self.csrf_token} if self.csrf_token else {} def auth(self) -> None: diff --git a/tests/api/clients/superset_test.py b/tests/api/clients/superset_test.py index b2fa291f..e9e05526 100644 --- a/tests/api/clients/superset_test.py +++ b/tests/api/clients/superset_test.py @@ -1875,7 +1875,7 @@ def test_get_uuids(requests_mock: Mocker) -> None: with bundle.open("metadata.yaml", "w") as output: output.write(b"Hello!") with bundle.open(name, "w") as output: - output.write(yaml.dump({"uuid": uuid}).encode()) + output.write(yaml.dump({"uuid": uuid}).encode()) # type: ignore buf.seek(0) requests_mock.get(