diff options
author | David Lord <davidism@gmail.com> | 2023-01-19 06:42:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-19 06:42:42 -0800 |
commit | 6ebe1acaab06a76c31d00668f9a8d44d9c4a2e5b (patch) | |
tree | e08ed6b10911377b50d1b8d51ff0699e474da517 | |
parent | 49ca689daa3b80abd7ac84690baff724a6cbb56a (diff) | |
parent | 876ce6ff93e27aa6527b2964a2112e9dab0ab352 (diff) | |
download | itsdangerous-6ebe1acaab06a76c31d00668f9a8d44d9c4a2e5b.tar.gz |
switch to pyproject.toml (#326)
-rw-r--r-- | .flake8 | 25 | ||||
-rw-r--r-- | .github/workflows/tests.yaml | 2 | ||||
-rw-r--r-- | .pre-commit-config.yaml | 5 | ||||
-rw-r--r-- | CHANGES.rst | 3 | ||||
-rw-r--r-- | pyproject.toml | 52 | ||||
-rw-r--r-- | setup.cfg | 98 | ||||
-rw-r--r-- | setup.py | 3 | ||||
-rw-r--r-- | src/itsdangerous/serializer.py | 10 |
8 files changed, 91 insertions, 107 deletions
@@ -0,0 +1,25 @@ +[flake8] +extend-select = + # bugbear + B + # bugbear opinions + B9 + # implicit str concat + ISC +extend-ignore = + # slice notation whitespace, invalid + E203 + # line length, handled by bugbear B950 + E501 + # bare except, handled by bugbear B001 + E722 + # zip with strict=, requires python >= 3.10 + B905 + # string formatting opinion, B028 renamed to B907 + B028 + B907 +# up to 88 allowed by bugbear B950 +max-line-length = 80 +per-file-ignores = + # __init__ exports names + src/itsdangerous/__init__.py: F401 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b757fa0..85e748b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -50,7 +50,7 @@ jobs: uses: actions/cache@v3 with: path: ./.mypy_cache - key: mypy|${{ matrix.python }}|${{ hashFiles('setup.cfg') }} + key: mypy|${{ matrix.python }}|${{ hashFiles('pyproject.toml') }} if: matrix.tox == 'typing' - run: pip install tox - run: tox run -e ${{ matrix.tox }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d41d19f..c3cc888 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,6 @@ repos: hooks: - id: reorder-python-imports args: ["--application-directories", "src:tests"] - additional_dependencies: ["setuptools>60.9"] - repo: https://github.com/psf/black rev: 22.12.0 hooks: @@ -21,7 +20,9 @@ repos: rev: 6.0.0 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear] + additional_dependencies: + - flake8-bugbear + - flake8-implicit-str-concat - repo: https://github.com/peterdemin/pip-compile-multi rev: v2.6.1 hooks: diff --git a/CHANGES.rst b/CHANGES.rst index d6a245e..2cf8fde 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,9 @@ Version 2.2.0 Unreleased +- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``. + :pr:`326` + Version 2.1.2 ------------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..fd20938 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[project] +name = "itsdangerous" +description = "Safely pass data to untrusted environments and back." +readme = "README.rst" +license = {text = "BSD-3-Clause"} +maintainers = [{name = "Pallets", email = "contact@palletsprojects.com"}] +authors = [{name = "Armin Ronacher", email = "armin.ronacher@active-4.com"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", +] +requires-python = ">=3.7" +dynamic = ["version"] + +[project.urls] +Donate = "https://palletsprojects.com/donate" +Documentation = "https://itsdangerous.palletsprojects.com/" +Changes = "https://itsdangerous.palletsprojects.com/changes/" +"Source Code" = "https://github.com/pallets/itsdangerous/" +"Issue Tracker" = "https://github.com/pallets/itsdangerous/issues/" +Twitter = "https://twitter.com/PalletsTeam" +Chat = "https://discord.gg/pallets" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "itsdangerous.__version__"} + +[tool.pytest.ini_options] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["itsdangerous", "tests"] + +[tool.coverage.paths] +source = ["src", "*/site-packages"] + +[tool.mypy] +python_version = "3.7" +files = ["src/itsdangerous"] +show_error_codes = true +pretty = true +strict = true +local_partial_types = true +warn_unreachable = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b650689..0000000 --- a/setup.cfg +++ /dev/null @@ -1,98 +0,0 @@ -[metadata] -name = itsdangerous -version = attr: itsdangerous.__version__ -url = https://palletsprojects.com/p/itsdangerous/ -project_urls = - Donate = https://palletsprojects.com/donate - Documentation = https://itsdangerous.palletsprojects.com/ - Changes = https://itsdangerous.palletsprojects.com/changes/ - Source Code = https://github.com/pallets/itsdangerous/ - Issue Tracker = https://github.com/pallets/itsdangerous/issues/ - Twitter = https://twitter.com/PalletsTeam - Chat = https://discord.gg/pallets -license = BSD-3-Clause -license_files = LICENSE.rst -author = Armin Ronacher -author_email = armin.ronacher@active-4.com -maintainer = Pallets -maintainer_email = contact@palletsprojects.com -description = Safely pass data to untrusted environments and back. -long_description = file: README.rst -long_description_content_type = text/x-rst -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python - -[options] -packages = find: -package_dir = = src -include_package_data = True -python_requires = >= 3.7 - -[options.packages.find] -where = src - -[tool:pytest] -testpaths = tests -filterwarnings = - error - -[coverage:run] -branch = True -source = - itsdangerous - tests - -[coverage:paths] -source = - src - */site-packages - -[flake8] -# B = bugbear -# E = pycodestyle errors -# F = flake8 pyflakes -# W = pycodestyle warnings -# B9 = bugbear opinions -# ISC = implicit str concat -select = B, E, F, W, B9, ISC -ignore = - # slice notation whitespace, invalid - E203 - # line length, handled by bugbear B950 - E501 - # bare except, handled by bugbear B001 - E722 - # bin op line break, invalid - W503 - # zip with strict=, requires python >= 3.10 - B905 -# up to 88 allowed by bugbear B950 -max-line-length = 80 -per-file-ignores = - # __init__ exports names - src/itsdangerous/__init__.py: F401 - -[mypy] -files = src/itsdangerous -python_version = 3.7 -show_error_codes = True -disallow_subclassing_any = True -disallow_untyped_calls = True -disallow_untyped_defs = True -disallow_incomplete_defs = True -no_implicit_optional = True -local_partial_types = True -no_implicit_reexport = True -strict_equality = True -warn_redundant_casts = True -warn_unused_configs = True -warn_unused_ignores = True -warn_return_any = True -warn_unreachable = True - -[mypy-itsdangerous.jws] -disallow_untyped_defs = False diff --git a/setup.py b/setup.py deleted file mode 100644 index 779a2c0..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup(name="itsdangerous") diff --git a/src/itsdangerous/serializer.py b/src/itsdangerous/serializer.py index 9f4a84a..1a66789 100644 --- a/src/itsdangerous/serializer.py +++ b/src/itsdangerous/serializer.py @@ -212,7 +212,9 @@ class Serializer: return rv - def dump(self, obj: _t.Any, f: _t.IO, salt: _t_opt_str_bytes = None) -> None: + def dump( + self, obj: _t.Any, f: _t.IO[_t.Any], salt: _t_opt_str_bytes = None + ) -> None: """Like :meth:`dumps` but dumps into a file. The file handle has to be compatible with what the internal serializer expects. """ @@ -235,7 +237,7 @@ class Serializer: raise _t.cast(BadSignature, last_exception) - def load(self, f: _t.IO, salt: _t_opt_str_bytes = None) -> _t.Any: + def load(self, f: _t.IO[_t.Any], salt: _t_opt_str_bytes = None) -> _t.Any: """Like :meth:`loads` but loads from a file.""" return self.loads(f.read(), salt) @@ -287,7 +289,9 @@ class Serializer: except BadPayload: return False, None - def load_unsafe(self, f: _t.IO, salt: _t_opt_str_bytes = None) -> _t_load_unsafe: + def load_unsafe( + self, f: _t.IO[_t.Any], salt: _t_opt_str_bytes = None + ) -> _t_load_unsafe: """Like :meth:`loads_unsafe` but loads from a file. .. versionadded:: 0.15 |