From e0255c4785303c6dc653aee8c757ce7698f6fc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Tr=C3=B6ger?= Date: Thu, 9 Dec 2021 18:01:58 +1000 Subject: [PATCH] chore: tweak project settings (#48) --- .github/workflows/pull-request.yml | 2 +- MANIFEST.in | 4 ++-- UPSTREAM_README.md | 4 +++- mypy.ini | 11 ++++++++--- setup.py | 24 ++++++++++++++---------- tox.ini | 5 +++++ 6 files changed, 33 insertions(+), 17 deletions(-) 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: 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/UPSTREAM_README.md b/UPSTREAM_README.md index a1d36627..88d765dd 100644 --- a/UPSTREAM_README.md +++ b/UPSTREAM_README.md @@ -58,7 +58,9 @@ 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. - If you’d like to publish your package to PyPI then set the `upload_to_pypi` variable in the `pyproject.toml` file to `true`. 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..09f1f1cc 100644 --- a/setup.py +++ b/setup.py @@ -27,26 +27,33 @@ 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=[ "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, 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