From a434ceae84ba800215e3fab11501b4e2ffd9ae06 Mon Sep 17 00:00:00 2001 From: David Lord Date: Thu, 19 Jan 2023 13:14:21 -0800 Subject: switch to pyproject.toml --- .flake8 | 22 ++++++++++ .github/workflows/tests.yaml | 2 +- CHANGES.rst | 9 +++++ pyproject.toml | 55 +++++++++++++++++++++++++ setup.cfg | 95 -------------------------------------------- setup.py | 1 - src/markupsafe/__init__.py | 2 +- 7 files changed, 88 insertions(+), 98 deletions(-) create mode 100644 .flake8 create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..07b9d8d --- /dev/null +++ b/.flake8 @@ -0,0 +1,22 @@ +[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 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a85f6c7..8178730 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -50,7 +50,7 @@ jobs: uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 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/CHANGES.rst b/CHANGES.rst index 81294a0..dacf85a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,12 @@ +Version 2.2.0 +------------- + +Unreleased + +- Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``. + :pr:`348` + + Version 2.1.2 ------------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5fdf079 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[project] +name = "MarkupSafe" +description = "Safely add untrusted strings to HTML/XML markup." +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", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Topic :: Internet :: WWW/HTTP :: Dynamic Content", + "Topic :: Text Processing :: Markup :: HTML", +] +requires-python = ">=3.7" +dynamic = ["version"] + +[project.urls] +Donate = "https://palletsprojects.com/donate" +Documentation = "https://markupsafe.palletsprojects.com/" +Changes = "https://markupsafe.palletsprojects.com/changes/" +"Source Code" = "https://github.com/pallets/markupsafe/" +"Issue Tracker" = "https://github.com/pallets/markupsafe/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 = "markupsafe.__version__"} + +[tool.pytest.ini_options] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["markupsafe", "tests"] + +[tool.coverage.paths] +source = ["src", "*/site-packages"] + +[tool.mypy] +python_version = "3.7" +files = ["src/markupsafe"] +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 139256d..0000000 --- a/setup.cfg +++ /dev/null @@ -1,95 +0,0 @@ -[metadata] -name = MarkupSafe -version = attr: markupsafe.__version__ -url = https://palletsprojects.com/p/markupsafe/ -project_urls = - Donate = https://palletsprojects.com/donate - Documentation = https://markupsafe.palletsprojects.com/ - Changes = https://markupsafe.palletsprojects.com/changes/ - Source Code = https://github.com/pallets/markupsafe/ - Issue Tracker = https://github.com/pallets/markupsafe/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 add untrusted strings to HTML/XML markup. -long_description = file: README.rst -long_description_content_type = text/x-rst -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Web Environment - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python - Topic :: Internet :: WWW/HTTP :: Dynamic Content - Topic :: Text Processing :: Markup :: HTML - -[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 = - markupsafe - 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 - -[mypy] -files = src/markupsafe -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 diff --git a/setup.py b/setup.py index d01eb74..7208cdd 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,6 @@ class ve_build_ext(build_ext): def run_setup(with_binary): setup( - name="MarkupSafe", cmdclass={"build_ext": ve_build_ext}, ext_modules=ext_modules if with_binary else [], ) diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py index 7166b19..31729a9 100644 --- a/src/markupsafe/__init__.py +++ b/src/markupsafe/__init__.py @@ -245,7 +245,7 @@ class EscapeFormatter(string.Formatter): return str(self.escape(rv)) -_ListOrDict = t.TypeVar("_ListOrDict", list, dict) +_ListOrDict = t.TypeVar("_ListOrDict", t.List[t.Any], t.Dict[t.Any, t.Any]) def _escape_argspec( -- cgit v1.2.1