From 430c33286f17625b649fd442aa70825fb1d8c84a Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 1 Aug 2021 12:04:03 +0200 Subject: [PATCH 1/3] chore: fix mypy pre-commit hook --- .mypy.ini | 9 --------- .pre-commit-config.yaml | 6 +++++- docs/__init__.py | 0 pyproject.toml | 22 ++++++++++++++++++++++ tests/__init__.py | 0 tests/functional/__init__.py | 0 tests/functional/api/__init__.py | 0 tests/functional/cli/__init__.py | 0 tests/unit/mixins/__init__.py | 0 tox.ini | 2 +- 10 files changed, 28 insertions(+), 11 deletions(-) delete mode 100644 .mypy.ini create mode 100644 docs/__init__.py create mode 100644 tests/__init__.py create mode 100644 tests/functional/__init__.py create mode 100644 tests/functional/api/__init__.py create mode 100644 tests/functional/cli/__init__.py create mode 100644 tests/unit/mixins/__init__.py diff --git a/.mypy.ini b/.mypy.ini deleted file mode 100644 index fdc64de46..000000000 --- a/.mypy.ini +++ /dev/null @@ -1,9 +0,0 @@ -[mypy] -files = gitlab/*.py,gitlab/v4/cli.py,gitlab/v4/objects/projects.py - -# disallow_incomplete_defs: This flag reports an error whenever it encounters a -# partly annotated function definition. -disallow_incomplete_defs = True -# disallow_untyped_defs: This flag reports an error whenever it encounters a -# function without type annotations or with incomplete type annotations. -disallow_untyped_defs = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8aa69b568..34a33b6d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,10 @@ repos: hooks: - id: isort - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.812 + rev: v0.910 hooks: - id: mypy + additional_dependencies: + # todo: sync with pip deps via renovate regex manager + - types-PyYAML==5.4.3 + - types-requests==2.25.1 diff --git a/docs/__init__.py b/docs/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/pyproject.toml b/pyproject.toml index 448a4e3db..0cd4c1b98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,28 @@ profile = "black" multi_line_output = 3 order_by_type = false +[tool.mypy] +disallow_incomplete_defs = true +disallow_untyped_defs = true + +[[tool.mypy.overrides]] # Overrides for currently untyped modules +module = [ + "docs.*", + "docs.ext.*", + "gitlab.v4.objects.*", + "setup", + "tests.functional.*", + "tests.functional.api.*", + "tests.unit.*" +] +ignore_errors = true + +[[tool.mypy.overrides]] # Overrides to negate above patterns +module = [ + "gitlab.v4.objects.projects" +] +ignore_errors = false + [tool.semantic_release] version_variable = "gitlab/__version__.py:__version__" commit_subject = "chore: release v{version}" diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/api/__init__.py b/tests/functional/api/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional/cli/__init__.py b/tests/functional/cli/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/mixins/__init__.py b/tests/unit/mixins/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tox.ini b/tox.ini index 1ddc33192..4cb6cd8eb 100644 --- a/tox.ini +++ b/tox.ini @@ -41,7 +41,7 @@ basepython = python3 envdir={toxworkdir}/lint deps = -r{toxinidir}/requirements-lint.txt commands = - mypy {posargs} + mypy {posargs} . [testenv:twine-check] basepython = python3 From 616be1ae320ed65e0b213fb4e4d9ebb69bcdad8a Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 1 Aug 2021 20:45:40 +0200 Subject: [PATCH 2/3] chore(deps): group typing requirements with mypy additional_dependencies --- .pre-commit-config.yaml | 1 - .renovaterc.json | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34a33b6d4..b6b38bf1b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,5 @@ repos: hooks: - id: mypy additional_dependencies: - # todo: sync with pip deps via renovate regex manager - types-PyYAML==5.4.3 - types-requests==2.25.1 diff --git a/.renovaterc.json b/.renovaterc.json index 319e22b07..df0650f86 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -12,12 +12,22 @@ "depNameTemplate": "gitlab/gitlab-ce", "datasourceTemplate": "docker", "versioningTemplate": "loose" + }, + { + "fileMatch": ["^.pre-commit-config.yaml$"], + "matchStrings": ["- (?.*?)==(?.*?)\n"], + "datasourceTemplate": "pypi", + "versioningTemplate": "pep440" } ], "packageRules": [ { "packagePatterns": ["^gitlab\/gitlab-.+$"], "automerge": true + }, + { + "matchPackagePrefixes": ["types-"], + "groupName": "typing dependencies" } ] } From ca475fc80ac556392fb8cb74731f6c66ce010646 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Sun, 22 Aug 2021 18:01:40 +0200 Subject: [PATCH 3/3] chore: define root dir in mypy, not tox --- pyproject.toml | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0cd4c1b98..27b5faa10 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ order_by_type = false [tool.mypy] disallow_incomplete_defs = true disallow_untyped_defs = true +files = "." [[tool.mypy.overrides]] # Overrides for currently untyped modules module = [ diff --git a/tox.ini b/tox.ini index 4cb6cd8eb..1ddc33192 100644 --- a/tox.ini +++ b/tox.ini @@ -41,7 +41,7 @@ basepython = python3 envdir={toxworkdir}/lint deps = -r{toxinidir}/requirements-lint.txt commands = - mypy {posargs} . + mypy {posargs} [testenv:twine-check] basepython = python3