From 279686476ff68578bcf7f4c01fda8f3a8cad8a5c Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Tue, 23 Nov 2021 06:59:34 +1000 Subject: [PATCH 1/6] chore: tweak project settings based on feedback from forks --- .pre-commit-config.yaml | 2 +- MANIFEST.in | 4 ++-- mypy.ini | 11 ++++++++--- setup.py | 10 +++++----- tox.ini | 5 +++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b07bc58a..50b94387 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,7 +67,7 @@ repos: - id: mypy files: ^src/package/|^tests/|setup.py additional_dependencies: [types-setuptools==57.4.2,hypothesis==6.30.1] - args: [--config-file, mypy.ini] + args: [--ignore-missing-imports, --config-file, mypy.ini] # Enable a whole bunch of useful helper hooks, too. # See https://pre-commit.com/hooks.html for more hooks. diff --git a/MANIFEST.in b/MANIFEST.in index afc75f5b..34d6432b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,7 @@ -recursive-include src/package +recursive-include src/package * exclude .gitignore .pre-commit-config.yaml -exclude CHANGELOG.md MANIFEST.in +exclude CHANGELOG.md MANIFEST.in UPSTREAM_README.md UPSTREAM_CHANGELOG.md exclude commitlint.rules.js mypy.ini pylintrc pyproject.toml tox.ini recursive-exclude .github * recursive-exclude docs * diff --git a/mypy.ini b/mypy.ini index 6a83001e..bfa8e3f7 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,7 +5,8 @@ # get consistent results on any platform. python_version=3.9 platform=linux -mypy_path = src +mypy_path=src +exclude= # Useful settings. show_column_numbers=True @@ -16,9 +17,13 @@ warn_return_any=True warn_redundant_casts=True warn_unused_ignores=True +# Ignore the following imports because they have no types available. +[mypy-pytest] +ignore_missing_imports=True + # Per-module options: strict checks. [mypy-src.*] disallow_untyped_calls=True disallow_untyped_defs=True -disallow_incomplete_defs = True -disallow_untyped_decorators = True +disallow_incomplete_defs=True +disallow_untyped_decorators=True diff --git a/setup.py b/setup.py index 62de3ffc..1d816feb 100644 --- a/setup.py +++ b/setup.py @@ -27,11 +27,11 @@ description="", long_description=README, long_description_content_type="text/markdown", - url="", - author="", - author_email="", - # maintainer= - # maintainer_email= + url="https://project.url/", + author="Author", + author_email="author@email", + maintainer="Maintainer", + maintainer_email="maintainer@email", license=LICENSE, # https://pypi.org/classifiers/ classifiers=[ diff --git a/tox.ini b/tox.ini index 84a067b2..1c4e182a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,19 @@ [tox] envlist = py39,py310 +# Ensure that tox runs Github Actions properly. +# https://github.com/ymyzk/tox-gh-actions [gh-actions] python = 3.9: py39 3.10: py310 +# Use pytest for testing and set up an optional environment for it. [testenv] extras = test commands = pytest +setenv = + SOME_VAR = "value" # Unfortunately, flake8 does not support pyproject.toml configuration. # https://github.com/PyCQA/flake8/issues/234 From 3901e366bf2d2da73fb4380304aa62a4a69476ee Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Tue, 30 Nov 2021 22:21:30 +1000 Subject: [PATCH 2/6] docs: add comment on ignoring type-less mypy imports --- UPSTREAM_README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UPSTREAM_README.md b/UPSTREAM_README.md index a1d36627..397ed258 100644 --- a/UPSTREAM_README.md +++ b/UPSTREAM_README.md @@ -60,6 +60,8 @@ If you’d like to start your own Python project from scratch, you can either co - Adjust the content of the `setup.py` file according to your needs, and reset the package’s version number in `src/package/__init__.py`. Don’t forget to delete the content of the `CHANGELOG.md` file (except for the first placeholder line). +- If you import packages that do not provide type hints into your new repository, then `mypy` needs to be configured accordingly: add these packages to the `mypy.ini` file using the [`ignore-missing-imports`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-ignore_missing_imports) option. + - If you’d like to publish your package to PyPI then set the `upload_to_pypi` variable in the `pyproject.toml` file to `true`. To develop your new package, create a [virtual environment](https://docs.python.org/3/tutorial/venv.html) and install its `dev`, `test` and `docs` dependencies: From 26d8c661fa78adb8e57c84ebed213e427914e684 Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Wed, 1 Dec 2021 08:18:38 +1000 Subject: [PATCH 3/6] chore: reorder package setup arguments --- setup.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 1d816feb..09f1f1cc 100644 --- a/setup.py +++ b/setup.py @@ -36,17 +36,24 @@ # https://pypi.org/classifiers/ classifiers=[ "Development Status :: 1 - Planning", + "Intended Audience :: Developers", + "Natural Language :: English", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: Implementation :: CPython", ], + python_requires=">=3.9", keywords="", project_urls={ "Homepage": "https://foo.bar/", }, - package_dir={"": "src"}, packages=setuptools.find_packages(where="src"), - python_requires=">=3.9", + package_dir={"": "src"}, + package_data={ + "package": ["py.typed"], + }, include_package_data=True, install_requires=[], extras_require={ @@ -65,9 +72,6 @@ ], "docs": ["sphinx==4.3.1"], }, - package_data={ - "package": ["py.typed"], - }, options={}, platforms="", zip_safe=False, From c021c2b52e971fb3326c3fe4dbd4fcecb0f324b5 Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Tue, 7 Dec 2021 11:48:01 +1000 Subject: [PATCH 4/6] docs: mention to update maintainer, author information in README --- UPSTREAM_README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPSTREAM_README.md b/UPSTREAM_README.md index 397ed258..88d765dd 100644 --- a/UPSTREAM_README.md +++ b/UPSTREAM_README.md @@ -58,7 +58,7 @@ If you’d like to start your own Python project from scratch, you can either co - Rename the `src/package/` folder to whatever your own package’s name will be, and adjust the Github Actions in `.github/workflows/`, `setup.py`, `pyproject.toml`, `pre-commit-config.yaml` and the unit tests accordingly. -- Adjust the content of the `setup.py` file according to your needs, and reset the package’s version number in `src/package/__init__.py`. Don’t forget to delete the content of the `CHANGELOG.md` file (except for the first placeholder line). +- Adjust the content of the `setup.py` file according to your needs, and make sure to fill in the project URL, maintainer and author information too. Don’t forget to reset the package’s version number in `src/package/__init__.py`. - If you import packages that do not provide type hints into your new repository, then `mypy` needs to be configured accordingly: add these packages to the `mypy.ini` file using the [`ignore-missing-imports`](https://mypy.readthedocs.io/en/stable/config_file.html#confval-ignore_missing_imports) option. From 04172fc5fe5abe2c8c3221899ea69f3c5c6482ae Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Thu, 9 Dec 2021 09:09:50 +1000 Subject: [PATCH 5/6] chore: remove mypy cmd line option --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50b94387..b07bc58a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -67,7 +67,7 @@ repos: - id: mypy files: ^src/package/|^tests/|setup.py additional_dependencies: [types-setuptools==57.4.2,hypothesis==6.30.1] - args: [--ignore-missing-imports, --config-file, mypy.ini] + args: [--config-file, mypy.ini] # Enable a whole bunch of useful helper hooks, too. # See https://pre-commit.com/hooks.html for more hooks. From 12e7cb919a33853578aef9ea0e3ca942820d7138 Mon Sep 17 00:00:00 2001 From: Jens Troeger Date: Thu, 9 Dec 2021 09:34:34 +1000 Subject: [PATCH 6/6] ci: pin commitlint Action to improve reproducibility --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 248cf8ee..86a21fda 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: CondeNast/conventional-pull-request-action@main + - uses: CondeNast/conventional-pull-request-action@v0.1.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: