From 12e45ed83b5bdb1729393ecfa3d16b64dedd68b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Tue, 27 Dec 2022 08:40:48 -0800 Subject: [PATCH] Fix the CI, bump tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- .github/workflows/check.yml | 8 ++++-- .markdownlint.yaml | 8 ++++++ .pre-commit-config.yaml | 54 +++++++++++++++++++++++++----------- CHANGES.rst | 5 ---- docs/conf.py | 11 ++++++-- pyproject.toml | 41 ++++++++++++++++++--------- setup.cfg | 49 -------------------------------- src/platformdirs/__init__.py | 10 ++++--- tests/test_api.py | 6 +++- tests/test_main.py | 2 +- tox.ini | 37 ++++++++++++------------ whitelist.txt | 2 ++ 12 files changed, 119 insertions(+), 114 deletions(-) create mode 100644 .markdownlint.yaml delete mode 100644 setup.cfg diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e0403cb..aa8066f 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,7 +19,7 @@ jobs: py: - "3.11" - "3.10" - - "pypy3.9" # ahead to start it earlier because takes longer + - "pypy3.9" # ahead to start it earlier because takes longer - "3.9" - "3.8" - "3.7" @@ -63,7 +63,9 @@ jobs: PYTEST_ADDOPTS: "-vv --durations=20" CI_RUN: "yes" - name: Rename coverage report file - run: import os; import sys; os.rename(f".tox/.coverage.{os.environ['TOXENV']}", f".tox/.coverage.{os.environ['TOXENV']}-{sys.platform}") + run: | + import os; import sys; + os.rename(f".tox/.coverage.{os.environ['TOXENV']}", f".tox/.coverage.{os.environ['TOXENV']}-{sys.platform}") shell: python - name: Upload coverage data uses: actions/upload-artifact@v3 @@ -136,7 +138,7 @@ jobs: publish: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - needs: [ check, coverage ] + needs: [check, coverage] runs-on: ubuntu-latest steps: - name: Setup python to build package diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..f30749b --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,8 @@ +MD013: + code_blocks: false + headers: false + line_length: 120 + tables: false + +MD046: + style: fenced diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7aed9e7..f482478 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast - id: check-builtin-literals @@ -11,25 +11,30 @@ repos: - id: debug-statements - id: end-of-file-fixer - id: trailing-whitespace + - repo: https://github.com/asottile/add-trailing-comma + rev: v2.4.0 + hooks: + - id: add-trailing-comma + args: [--py36-plus] - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.3.1 hooks: - id: pyupgrade - args: [ "--py36-plus" ] + args: ["--py37-plus"] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.11.4 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - args: [ --safe ] + args: [--safe] - repo: https://github.com/asottile/blacken-docs rev: v1.12.1 hooks: - id: blacken-docs - additional_dependencies: [ black==22.10 ] + additional_dependencies: [black==22.12] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.9.0 hooks: @@ -38,16 +43,33 @@ repos: rev: "0.5.2" hooks: - id: tox-ini-fmt - args: [ "-p", "fix" ] + args: ["-p", "fix"] - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: - - flake8-bugbear==22.10.27 - - flake8-comprehensions==3.10.1 - - flake8-pytest-style==1.6 - - flake8-spellcheck==0.28 - - flake8-unused-arguments==0.0.12 - - flake8-noqa==1.2.9 - - pep8-naming==0.13.2 + - flake8-bugbear==22.12.6 + - flake8-comprehensions==3.10.1 + - flake8-pytest-style==1.6 + - flake8-spellcheck==0.28 + - flake8-unused-arguments==0.0.12 + - flake8-noqa==1.3 + - pep8-naming==0.13.3 + - flake8-pyproject==1.2.2 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v2.7.1" + hooks: + - id: prettier + additional_dependencies: + - prettier@3.0.0-alpha.4 + - "@prettier/plugin-xml@2.2" + args: ["--print-width=120", "--prose-wrap=always"] + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.32.2 + hooks: + - id: markdownlint + - repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes diff --git a/CHANGES.rst b/CHANGES.rst index 710ddad..139a02d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,11 +20,6 @@ platformdirs 2.5.2 (2022-04-18) - Move packaging to hatcling from setuptools - Treat android shells as unix -platformdirs 2.5.2 (2022-04-18) -------------------------------- -- Move packaging to hatcling from setuptools -- Treat android shells as unix - platformdirs 2.5.1 (2022-02-19) ------------------------------- - Add native support for nuitka diff --git a/docs/conf.py b/docs/conf.py index 0810918..28d9134 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,7 @@ from __future__ import annotations +from datetime import datetime + from platformdirs.version import __version__ author = "The platformdirs team" @@ -13,14 +15,17 @@ "sphinx.ext.autosectionlabel", "sphinx.ext.viewcode", "sphinx.ext.intersphinx", - # "sphinx_autodoc_typehints", + "sphinx_autodoc_typehints", ] html_theme = "furo" - +html_title, html_last_updated_fmt = "tox", datetime.now().isoformat() +pygments_style, pygments_dark_style = "sphinx", "monokai" +autoclass_content, autodoc_member_order, autodoc_typehints = "class", "bysource", "none" autodoc_default_options = { "member-order": "bysource", "undoc-members": True, + "show-inheritance": True, } default_role = "any" -autodoc_typehints = "signature" +autosectionlabel_prefix_document = True intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} diff --git a/pyproject.toml b/pyproject.toml index dcf6735..f383403 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] build-backend = "hatchling.build" -requires = ["hatchling>=1.11.1", "hatch-vcs>=0.2"] +requires = ["hatchling>=1.11.1", "hatch-vcs>=0.3"] [project] name = "platformdirs" @@ -20,16 +20,12 @@ urls.Tracker = "https://github.com/platformdirs/platformdirs/issues" requires-python = ">=3.7" optional-dependencies.test = [ "appdirs==1.4.4", + "covdefaults>=2.2.2", "pytest>=7.2", "pytest-cov>=4", "pytest-mock>=3.10", ] -optional-dependencies.docs = [ - "furo>=2022.9.29", - "proselint>=0.13", - "sphinx>=5.3", - "sphinx-autodoc-typehints>=1.19.4", -] +optional-dependencies.docs = ["furo>=2022.12.7", "proselint>=0.13", "sphinx>=5.3", "sphinx-autodoc-typehints>=1.19.5"] keywords = ["application", "cache", "directory", "log", "user"] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -51,18 +47,37 @@ classifiers = [ dynamic = ["version"] [tool.hatch] -build.hooks.vcs.template = ''' -"""Version information""" - -__version__ = "{version}" -__version_info__ = {version_tuple} -''' build.hooks.vcs.version-file = "src/platformdirs/version.py" +build.targets.sdist.include = ["/src", "/tests"] version.source = "vcs" +[tool.coverage] +html.show_contexts = true +html.skip_covered = false +paths.source = ["src", ".tox/*/lib/*/site-packages", ".tox\\*\\Lib\\site-packages", "*/src", "*\\src"] +report.fail_under = 76 +run.parallel = true +run.plugins = ["covdefaults"] + [tool.black] line-length = 120 [tool.isort] profile = "black" known_first_party = ["platformdirs"] + +[tool.mypy] +python_version = "3.11" +show_error_codes = true +strict = true +overrides = [{ module = ["appdirs.*", "jnius.*"], ignore_missing_imports = true }] + +[tool.pep8] +max-line-length = "120" + +[tool.flake8] +max-complexity = 22 +max-line-length = 120 +unused-arguments-ignore-abstract-functions = true +noqa-require-code = true +dictionaries = ["en_US", "python", "technical", "django"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 21cef39..0000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[flake8] -max-complexity = 22 -max-line-length = 120 -noqa-require-code = true -dictionaries = en_US,python,technical,django - -[coverage:report] -show_missing = True -exclude_lines = - \#\s*pragma: no cover - ^\s*raise AssertionError\b - ^\s*raise NotImplementedError\b - ^\s*raise$ - ^if __name__ == ['"]__main__['"]:$ - -[coverage:paths] -source = - src - .tox/*/lib/python*/site-packages - .tox/pypy*/site-packages - .tox\*\Lib\site-packages\ - */src - *\src -other = - . - */platformdirs - *\platformdirs - -[coverage:run] -branch = true -parallel = true -dynamic_context = test_function -source = - ${_COVERAGE_SRC} - -[coverage:html] -show_contexts = true -skip_covered = false -skip_empty = true - -[mypy] -python_version = 3.9 -warn_unused_ignores = False - -[mypy-appdirs.*] -ignore_missing_imports = True - -[mypy-jnius.*] -ignore_missing_imports = True diff --git a/src/platformdirs/__init__.py b/src/platformdirs/__init__.py index a2d730c..3147a69 100644 --- a/src/platformdirs/__init__.py +++ b/src/platformdirs/__init__.py @@ -7,13 +7,15 @@ import os import sys from pathlib import Path -from typing import TYPE_CHECKING -if TYPE_CHECKING: - from typing_extensions import Literal # pragma: no cover +if sys.version_info >= (3, 8): # pragma: no cover (py38+) + from typing import Literal +else: # pragma: no cover (py38+) + from typing_extensions import Literal from .api import PlatformDirsABC -from .version import __version__, __version_info__ +from .version import __version__ +from .version import __version_tuple__ as __version_info__ def _set_platform_dir_class() -> type[PlatformDirsABC]: diff --git a/tests/test_api.py b/tests/test_api.py index 6ac104f..470b206 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -55,7 +55,11 @@ def test_function_interface_is_in_sync(func: str) -> None: @pytest.mark.parametrize("path", ["/data/data/a/files", "/C"]) @pytest.mark.parametrize("shell", ["/data/data/com.app/files/usr/bin/sh", "/usr/bin/sh", None]) def test_android_active( - monkeypatch: MonkeyPatch, root: str | None, data: str | None, path: str, shell: str | None + monkeypatch: MonkeyPatch, + root: str | None, + data: str | None, + path: str, + shell: str | None, ) -> None: for env_var, value in {"ANDROID_DATA": data, "ANDROID_ROOT": root, "SHELL": shell}.items(): if value is None: diff --git a/tests/test_main.py b/tests/test_main.py index d09e18a..7ea1797 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -12,7 +12,7 @@ def test_props_same_as_test(props: tuple[str, ...]) -> None: def test_run_as_module() -> None: - out = check_output([sys.executable, "-m", "platformdirs"], universal_newlines=True) + out = check_output([sys.executable, "-m", "platformdirs"], text=True) assert out.startswith(f"-- platformdirs {__version__} --") for prop in PROPS: diff --git a/tox.ini b/tox.ini index 62ca639..fc75ad2 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ envlist = type coverage readme + docs isolated_build = true skip_missing_interpreters = true minversion = 3.21 @@ -21,7 +22,7 @@ passenv = ANDROID_ROOT setenv = COVERAGE_FILE = {toxworkdir}/.coverage.{envname} - COVERAGE_PROCESS_START = {toxinidir}/setup.cfg + COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml _COVERAGE_SRC = {envsitepackagesdir}/platformdirs extras = test @@ -29,7 +30,7 @@ commands = pytest {tty:--color=yes} {posargs: \ --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}platformdirs \ --cov {toxinidir}{/}tests \ - --cov-config=setup.cfg --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ + --cov-config=pyproject.toml --no-cov-on-fail --cov-report term-missing:skip-covered --cov-context=test \ --cov-report html:{envtmpdir}{/}htmlcov --cov-report xml:{toxworkdir}{/}coverage.{envname}.xml \ tests} package = wheel @@ -42,7 +43,7 @@ passenv = PROGRAMDATA skip_install = true deps = - pre-commit>=2.20 + pre-commit>=2.21 commands = pre-commit run --all-files --show-diff-on-failure @@ -51,7 +52,7 @@ description = run type check on code base setenv = {tty:MYPY_FORCE_COLOR = 1} deps = - mypy==0.982 + mypy==0.991 commands = mypy --strict src mypy --strict tests @@ -64,9 +65,9 @@ setenv = COVERAGE_FILE = {toxworkdir}/.coverage skip_install = true deps = - covdefaults>=2.2 - coverage>=6.5 - diff-cover>=7.0.1 + covdefaults>=2.2.2 + coverage>=7.0.1 + diff-cover>=7.3 extras = parallel_show_output = true commands = @@ -90,22 +91,14 @@ passenv = skip_install = true deps = build[virtualenv]>=0.9 - twine>=4.0.1 + twine>=4.0.2 changedir = {toxinidir} commands = python -m build -o {envtmpdir} . twine check {envtmpdir}/* -[testenv:dev] -description = generate a DEV environment -usedevelop = true -extras = - test -commands = - python -m pip list --format=columns - python -c 'import sys; print(sys.executable)' - [testenv:docs] +basepython = 3.10 extras = docs commands = @@ -113,5 +106,11 @@ commands = sphinx-build -d "{envtmpdir}/doctree" docs "{toxworkdir}/docs_out" --color -b html {posargs} python -c 'import pathlib; print("documentation available under \{0\}".format((pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html").as_uri()))' -[pytest] -junit_family = xunit2 +[testenv:dev] +description = generate a DEV environment +usedevelop = true +extras = + test +commands = + python -m pip list --format=columns + python -c 'import sys; print(sys.executable)' diff --git a/whitelist.txt b/whitelist.txt index 3ee14c7..8d61a14 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -3,6 +3,7 @@ appdirs appname autoclass autodoc +autosectionlabel buf buf2 csidl @@ -16,6 +17,7 @@ jnius macos multipath platformdirs +pygments pyjnius setenv shell32