diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1362b4..0796497 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.7', '3.8', '3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 @@ -39,7 +39,7 @@ jobs: run: tox -e pytest -- tests -m end_to_end --cov=./ --cov-report=xml -n auto - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 729026b..801f3a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,11 @@ repos: - id: check-merge-conflict - id: check-vcs-permalinks - id: check-yaml - exclude: "{{cookiecutter.project_slug}}/environment.yml" + exclude: | + (?x)^( + {{cookiecutter.project_slug}}/environment.yml| + {{cookiecutter.project_slug}}/.pre-commit-config.yaml + )$ - id: debug-statements - id: end-of-file-fixer - id: fix-byte-order-marker @@ -74,7 +78,13 @@ repos: rev: 1.5.0 hooks: - id: interrogate - args: [-v, --fail-under=40, "{{cookiecutter.project_slug}}"] + args: [ + -v, + --fail-under=40, + --config, + pyproject.toml, + "{{cookiecutter.project_slug}}" + ] pass_filenames: false - repo: https://github.com/codespell-project/codespell rev: v2.1.0 diff --git a/cookiecutter.json b/cookiecutter.json index dc7291c..5d61e27 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -10,6 +10,7 @@ "python_version": "3.8", "add_tox": ["yes", "no"], "add_github_actions": ["yes", "no"], + "add_mypy": ["yes", "no"], "add_readthedocs": ["yes", "no"], "add_codecov": ["yes", "no"], "create_changelog": ["yes", "no"], diff --git a/docs/source/conf.py b/docs/source/conf.py index 4e6a941..9bc4075 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,6 +6,7 @@ """ # -- Project information ----------------------------------------------------- + project = "cookiecutter-pytask-project" author = "Tobias Raabe" copyright = f"2021, {author}" # noqa: A001 diff --git a/environment.yml b/environment.yml index 577fb20..6b35fd3 100644 --- a/environment.yml +++ b/environment.yml @@ -12,7 +12,7 @@ dependencies: # Package dependencies - cookiecutter - - pytask + - pytask >=0.1.7 # Misc - black diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 1125117..04e566f 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -3,7 +3,7 @@ MODULE_REGEX = r"^[-_a-zA-Z0-9]*$" ENVIRON_REGEX = r"^[-_a-zA-Z0-9]*$" -PYTHONVERSION_REGEX = r"^(3)\.[6-9]$" +PYTHONVERSION_REGEX = r"^(3\.(10|[7-9])(\.[0-9]{1,2})?)$" EXCEPTION_MSG_MODULE_NAME = """ ERROR: The project slug ({module_name}) is not a valid Python module name. @@ -33,7 +33,7 @@ def main(): python_version = "{{ cookiecutter.python_version }}" if not re.match(PYTHONVERSION_REGEX, python_version): - raise ValueError("ERROR: The python version must be >= 3.6") # noqa: TC003 + raise ValueError("ERROR: The python version must be >= 3.7") # noqa: TC003 if __name__ == "__main__": diff --git a/tests/__init__.py b/tests/__init__.py index 6cc8cb4..4045499 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -"""This file is necessary to apply custom mypy configurations for the tests.""" +"""This module is necessary to configure mypy's behavior for the tests.""" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/main.yml b/{{cookiecutter.project_slug}}/.github/workflows/main.yml index b8df04f..ea94885 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/main.yml @@ -25,7 +25,7 @@ jobs: fail-fast: false matrix: os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - python-version: ['3.7', '3.8', '3.9'] + python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - uses: actions/checkout@v2 @@ -45,7 +45,7 @@ jobs: run: tox -e pytest -- src tests -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto - name: Upload coverage report for unit tests and doctests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F unit -c @@ -54,7 +54,7 @@ jobs: run: tox -e pytest -- src tests -m integration --cov=./ --cov-report=xml -n auto - name: Upload coverage reports of integration tests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F integration -c @@ -63,7 +63,7 @@ jobs: run: tox -e pytest -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' + if: runner.os == 'Linux' && matrix.python-version == '3.9' shell: bash -l {0} run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index b706528..39dfed0 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -35,7 +35,8 @@ repos: - repo: https://github.com/asottile/reorder_python_imports rev: v2.7.1 hooks: - - id: reorder-python-imports + - id: reorder-python-imports{% if cookiecutter.add_mypy == "yes" %} + args: [--py37-plus, --add-import, 'from __future__ import annotations']{% endif %} - repo: https://github.com/asottile/setup-cfg-fmt rev: v1.20.0 hooks: @@ -86,7 +87,7 @@ repos: rev: v1.0.1 hooks: - id: tryceratops -- repo: https://github.com/pre-commit/mirrors-mypy +{% if cookiecutter.add_mypy == "yes" %}- repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.931' hooks: - id: mypy @@ -95,7 +96,7 @@ repos: --ignore-missing-imports, ] pass_filenames: false -- repo: meta +{% endif %}- repo: meta hooks: - id: check-hooks-apply - id: check-useless-excludes diff --git a/{{cookiecutter.project_slug}}/LICENSE b/{{cookiecutter.project_slug}}/LICENSE index cfcfbfb..01e1d4c 100644 --- a/{{cookiecutter.project_slug}}/LICENSE +++ b/{{cookiecutter.project_slug}}/LICENSE @@ -758,5 +758,4 @@ into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. -{% endif %} +.{% endif %} diff --git a/{{cookiecutter.project_slug}}/README.rst b/{{cookiecutter.project_slug}}/README.rst index 964e06d..1a6c493 100644 --- a/{{cookiecutter.project_slug}}/README.rst +++ b/{{cookiecutter.project_slug}}/README.rst @@ -39,5 +39,5 @@ Credits ------- This project was created with `cookiecutter `_ -and the `cookiecutter-pytask-project `_ -template. +and the `cookiecutter-pytask-project +`_ template. diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 870324e..1805e3e 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -5,7 +5,7 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] [tool.setuptools_scm] write_to = "src/{{ cookiecutter.project_slug }}/_version.py" - +{% if cookiecutter.add_mypy == "yes" %} [tool.mypy] files = ["src", "tests"] check_untyped_defs = true @@ -21,3 +21,4 @@ warn_unused_ignores = true module = "tests.*" disallow_untyped_defs = false ignore_errors = true +{% endif %} diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 1eb243c..a10a8ad 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -17,7 +17,6 @@ classifiers = Operating System :: POSIX Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 @@ -32,7 +31,7 @@ project_urls = packages = find: install_requires = pytask -python_requires = >=3.6.1 +python_requires = >=3.7 include_package_data = True package_dir = =src diff --git a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py index 4ae341a..df50b41 100644 --- a/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py +++ b/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/config.py @@ -5,8 +5,6 @@ try: from ._version import version as __version__ except ImportError: - # broken installation, we don't even try unknown only works because we do poor mans - # version compare __version__ = "unknown" diff --git a/{{cookiecutter.project_slug}}/tests/__init__.py b/{{cookiecutter.project_slug}}/tests/__init__.py index e69de29..4045499 100644 --- a/{{cookiecutter.project_slug}}/tests/__init__.py +++ b/{{cookiecutter.project_slug}}/tests/__init__.py @@ -0,0 +1 @@ +"""This module is necessary to configure mypy's behavior for the tests."""