From 32dab78367e1ee48087e7e118922591bc9021cf6 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 4 May 2021 20:17:54 +0100 Subject: [PATCH 1/8] Fix compatibility with Python 3.10 beta 1 --- domdf_python_tools/paths.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/domdf_python_tools/paths.py b/domdf_python_tools/paths.py index 0385bb42..2455f886 100644 --- a/domdf_python_tools/paths.py +++ b/domdf_python_tools/paths.py @@ -361,7 +361,12 @@ class PathPlus(pathlib.Path): .. versionchanged:: 0.5.1 Defaults to Unix line endings (``LF``) on all platforms. """ - __slots__ = ("_accessor", ) + __slots__ = () + _accessor = pathlib._normal_accessor # type: ignore + _closed = False + + def _init(self, *args, **kwargs): + pass def __new__(cls, *args, **kwargs): # noqa D102 if cls is PathPlus: @@ -746,7 +751,7 @@ def unlink(self, missing_ok: bool = False) -> None: """ try: - self._accessor.unlink(self) # type: ignore + self._accessor.unlink(self) except FileNotFoundError: if not missing_ok: raise From 1a492aafa9ff52d66719948a00a0b8a96522f8b5 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 4 May 2021 20:41:36 +0100 Subject: [PATCH 2/8] More CPython 3.10 compatibility fixes --- domdf_python_tools/paths.py | 4 +++ tests/test_paths_stdlib.py | 55 ++++++++++++++----------------------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/domdf_python_tools/paths.py b/domdf_python_tools/paths.py index 2455f886..4b7bfe54 100644 --- a/domdf_python_tools/paths.py +++ b/domdf_python_tools/paths.py @@ -368,6 +368,10 @@ class PathPlus(pathlib.Path): def _init(self, *args, **kwargs): pass + @classmethod + def _from_parts(cls, args, init=True): + return super()._from_parts(args) # type: ignore + def __new__(cls, *args, **kwargs): # noqa D102 if cls is PathPlus: cls = WindowsPathPlus if os.name == "nt" else PosixPathPlus diff --git a/tests/test_paths_stdlib.py b/tests/test_paths_stdlib.py index 386da1ed..ac2f7c04 100644 --- a/tests/test_paths_stdlib.py +++ b/tests/test_paths_stdlib.py @@ -50,22 +50,8 @@ def _umask_0(): os.umask(old_mask) -def symlink_skip_reason(): - if not pathlib.supports_symlinks: # type: ignore - return "no system support for symlinks" - - try: - with tempfile.TemporaryDirectory() as tmpdir: - os.symlink(__file__, os.path.join(tmpdir, "foo.py")) - except (OSError, NotImplementedError) as e: # NotImplementedError is raised by PyPy - return str(e) - return None - - -symlink_skip_reason = symlink_skip_reason() only_nt = pytest.mark.skipif(condition=os.name != "nt", reason="test requires a Windows-compatible system") only_posix = pytest.mark.skipif(condition=os.name == "nt", reason="test requires a POSIX-compatible system") -with_symlinks = unittest.skipIf(symlink_skip_reason, symlink_skip_reason) # type: ignore @pytest.fixture() @@ -99,14 +85,14 @@ def dirlink(src, dest): with open(join("dirC", "dirD", "fileD"), "wb") as f: f.write(b"this is file D\n") os.chmod(join("dirE"), 0) - if not symlink_skip_reason: - # Relative symlinks. - os.symlink("fileA", join("linkA")) - os.symlink("non-existing", join("brokenLink")) - dirlink("dirB", join("linkB")) - dirlink(os.path.join("..", "dirB"), join("dirA", "linkC")) - # This one goes upwards, creating a loop. - dirlink(os.path.join("..", "dirB"), join("dirB", "linkD")) + + # Relative symlinks. + os.symlink("fileA", join("linkA")) + os.symlink("non-existing", join("brokenLink")) + dirlink("dirB", join("linkB")) + dirlink(os.path.join("..", "dirB"), join("dirA", "linkC")) + # This one goes upwards, creating a loop. + dirlink(os.path.join("..", "dirB"), join("dirB", "linkD")) yield tmp_pathplus @@ -468,7 +454,6 @@ def my_mkdir(path, mode=0o777): assert (p.exists()) -@with_symlinks def test_symlink_to(BASE): P = PathPlus(BASE) target = P / "fileA" @@ -499,10 +484,10 @@ def test_is_dir(BASE): assert not ((P / "fileA").is_dir()) assert not ((P / "non-existing").is_dir()) assert not ((P / "fileA" / "bah").is_dir()) - if not symlink_skip_reason: - assert not ((P / "linkA").is_dir()) - assert ((P / "linkB").is_dir()) - assert not (P / "brokenLink").is_dir() + + assert not ((P / "linkA").is_dir()) + assert ((P / "linkB").is_dir()) + assert not (P / "brokenLink").is_dir() def test_is_file(BASE): @@ -511,10 +496,10 @@ def test_is_file(BASE): assert not ((P / "dirA").is_file()) assert not ((P / "non-existing").is_file()) assert not ((P / "fileA" / "bah").is_file()) - if not symlink_skip_reason: - assert ((P / "linkA").is_file()) - assert not ((P / "linkB").is_file()) - assert not ((P / "brokenLink").is_file()) + + assert ((P / "linkA").is_file()) + assert not ((P / "linkB").is_file()) + assert not ((P / "brokenLink").is_file()) @only_posix @@ -536,10 +521,10 @@ def test_is_symlink(BASE): assert not ((P / "dirA").is_symlink()) assert not ((P / "non-existing").is_symlink()) assert not ((P / "fileA" / "bah").is_symlink()) - if not symlink_skip_reason: - assert ((P / "linkA").is_symlink()) - assert ((P / "linkB").is_symlink()) - assert ((P / "brokenLink").is_symlink()) + + assert ((P / "linkA").is_symlink()) + assert ((P / "linkB").is_symlink()) + assert ((P / "brokenLink").is_symlink()) def test_is_fifo_false(BASE): From 607abbad14504949cef8e2ba9f75d24e91248906 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 4 May 2021 21:50:35 +0100 Subject: [PATCH 3/8] Fix tests with PyPy on Windows --- tests/test_paths_stdlib.py | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/test_paths_stdlib.py b/tests/test_paths_stdlib.py index ac2f7c04..a001f457 100644 --- a/tests/test_paths_stdlib.py +++ b/tests/test_paths_stdlib.py @@ -24,6 +24,7 @@ import pytest # this package +from domdf_python_tools.compat import PYPY from domdf_python_tools.paths import PathPlus, PosixPathPlus, WindowsPathPlus try: @@ -86,13 +87,14 @@ def dirlink(src, dest): f.write(b"this is file D\n") os.chmod(join("dirE"), 0) - # Relative symlinks. - os.symlink("fileA", join("linkA")) - os.symlink("non-existing", join("brokenLink")) - dirlink("dirB", join("linkB")) - dirlink(os.path.join("..", "dirB"), join("dirA", "linkC")) - # This one goes upwards, creating a loop. - dirlink(os.path.join("..", "dirB"), join("dirB", "linkD")) + if not PYPY and sys.platform != "win32": + # Relative symlinks. + os.symlink("fileA", join("linkA")) + os.symlink("non-existing", join("brokenLink")) + dirlink("dirB", join("linkB")) + dirlink(os.path.join("..", "dirB"), join("dirA", "linkC")) + # This one goes upwards, creating a loop. + dirlink(os.path.join("..", "dirB"), join("dirB", "linkD")) yield tmp_pathplus @@ -485,9 +487,10 @@ def test_is_dir(BASE): assert not ((P / "non-existing").is_dir()) assert not ((P / "fileA" / "bah").is_dir()) - assert not ((P / "linkA").is_dir()) - assert ((P / "linkB").is_dir()) - assert not (P / "brokenLink").is_dir() + if not PYPY and sys.platform != "win32": + assert not ((P / "linkA").is_dir()) + assert ((P / "linkB").is_dir()) + assert not (P / "brokenLink").is_dir() def test_is_file(BASE): @@ -497,9 +500,10 @@ def test_is_file(BASE): assert not ((P / "non-existing").is_file()) assert not ((P / "fileA" / "bah").is_file()) - assert ((P / "linkA").is_file()) - assert not ((P / "linkB").is_file()) - assert not ((P / "brokenLink").is_file()) + if not PYPY and sys.platform != "win32": + assert ((P / "linkA").is_file()) + assert not ((P / "linkB").is_file()) + assert not ((P / "brokenLink").is_file()) @only_posix @@ -522,9 +526,10 @@ def test_is_symlink(BASE): assert not ((P / "non-existing").is_symlink()) assert not ((P / "fileA" / "bah").is_symlink()) - assert ((P / "linkA").is_symlink()) - assert ((P / "linkB").is_symlink()) - assert ((P / "brokenLink").is_symlink()) + if not PYPY and sys.platform != "win32": + assert ((P / "linkA").is_symlink()) + assert ((P / "linkB").is_symlink()) + assert ((P / "brokenLink").is_symlink()) def test_is_fifo_false(BASE): From 34196b1e4543f93620426004e5a375aa012196f4 Mon Sep 17 00:00:00 2001 From: "repo-helper[bot]" <74742576+repo-helper[bot]@users.noreply.github.com> Date: Tue, 4 May 2021 20:28:16 +0100 Subject: [PATCH 4/8] Updated files with 'repo_helper'. (#60) Co-authored-by: repo-helper[bot] <74742576+repo-helper[bot]@users.noreply.github.com> (cherry picked from commit 931592edfcdd0f360220c559571728659df25fc8) --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/actions_build_conda.sh | 2 +- .github/workflows/conda_ci.yml | 3 + .github/workflows/docs_test_action.yml | 18 +++- .github/workflows/flake8.yml | 17 +++- .github/workflows/mypy.yml | 14 ++++ .github/workflows/python_ci.yml | 24 +++++- .github/workflows/python_ci_linux.yml | 24 +++++- .github/workflows/python_ci_macos.yml | 24 +++++- .pre-commit-config.yaml | 2 +- doc-source/conf.py | 111 +++++-------------------- pyproject.toml | 79 ++++++++++++++++++ 12 files changed, 213 insertions(+), 107 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e36d5cc1..c717ce13 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -44,7 +44,7 @@ If possible, please include a small, self-contained reproduction. * domdf_python_tools: ## Installation source - + ## Other Additional Information: diff --git a/.github/actions_build_conda.sh b/.github/actions_build_conda.sh index 4983f899..01676e9f 100755 --- a/.github/actions_build_conda.sh +++ b/.github/actions_build_conda.sh @@ -3,7 +3,7 @@ set -e -x -python -m mkrecipe || exit 1 +python -m mkrecipe --type wheel || exit 1 # Switch to miniconda source "/home/runner/miniconda/etc/profile.d/conda.sh" diff --git a/.github/workflows/conda_ci.yml b/.github/workflows/conda_ci.yml index 7b4cef1f..ec5b69ca 100644 --- a/.github/workflows/conda_ci.yml +++ b/.github/workflows/conda_ci.yml @@ -6,6 +6,9 @@ on: push: branches: ["master"] +permissions: + contents: read + jobs: tests: name: "Conda" diff --git a/.github/workflows/docs_test_action.yml b/.github/workflows/docs_test_action.yml index 43c27755..77fa347d 100644 --- a/.github/workflows/docs_test_action.yml +++ b/.github/workflows/docs_test_action.yml @@ -4,15 +4,29 @@ name: "Docs Check" on: - push +permissions: + contents: read + jobs: docs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v1" + + - name: Check for changed files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!tests/**' + - name: Install and Build πŸ”§ - uses: ammaraskar/sphinx-action@master + uses: sphinx-toolbox/sphinx-action@sphinx-3.3.1 + if: steps.changes.outputs.code == 'true' with: - pre-build-command: apt-get update && apt-get install gcc python3-dev git pandoc -y && python -m pip install tox + pre-build-command: python -m pip install tox docs-folder: "doc-source/" build-command: "tox -e docs -- -W " diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 29303d6c..742dfdd7 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -5,6 +5,9 @@ name: Flake8 on: push: +permissions: + contents: read + jobs: Run: name: "Flake8" @@ -14,12 +17,23 @@ jobs: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v2" + - name: Check for changed files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' + - name: Setup Python 🐍 + if: steps.changes.outputs.code == 'true' uses: "actions/setup-python@v2" with: - python-version: "3.8" + python-version: "3.6" - name: Install dependencies πŸ”§ + if: steps.changes.outputs.code == 'true' run: | python -VV python -m site @@ -27,4 +41,5 @@ jobs: python -m pip install tox - name: "Run Flake8" + if: steps.changes.outputs.code == 'true' run: "python -m tox -e lint -- --format github" diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index e10cf9ba..43f22f72 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -5,6 +5,9 @@ name: mypy on: push: +permissions: + contents: read + jobs: Run: name: "mypy / ${{ matrix.os }}" @@ -19,7 +22,17 @@ jobs: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v2" + - name: Check for changed files + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' + - name: Setup Python 🐍 + if: steps.changes.outputs.code == 'true' uses: "actions/setup-python@v2" with: python-version: "3.6" @@ -32,4 +45,5 @@ jobs: python -m pip install --upgrade tox virtualenv - name: "Run mypy" + if: steps.changes.outputs.code == 'true' run: "python -m tox -e mypy" diff --git a/.github/workflows/python_ci.yml b/.github/workflows/python_ci.yml index 0c1bdda3..e035de81 100644 --- a/.github/workflows/python_ci.yml +++ b/.github/workflows/python_ci.yml @@ -5,13 +5,17 @@ name: Windows on: push: +permissions: + actions: write + contents: read + jobs: tests: name: "windows-2019 / Python ${{ matrix.config.python-version }}" runs-on: "windows-2019" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.6,pypy-3.6,pypy-3.7' + USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-beta.1,pypy-3.6,pypy-3.7' strategy: fail-fast: False @@ -21,7 +25,7 @@ jobs: - {python-version: "3.7", testenvs: "py37,build", experimental: False} - {python-version: "3.8", testenvs: "py38,build", experimental: False} - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.6", testenvs: "py310-dev,build", experimental: True} + - {python-version: "3.10.0-beta.1", testenvs: "py310-dev,build", experimental: True} - {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False} - {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: True} @@ -29,12 +33,25 @@ jobs: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v2" + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' + - name: Setup Python 🐍 + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} uses: "actions/setup-python@v2" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies πŸ”§ + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site @@ -42,11 +59,12 @@ jobs: python -m pip install --upgrade tox virtualenv - name: "Run Tests for Python ${{ matrix.config.python-version }}" + if: steps.setup-python.outcome == 'success' run: python -m tox -e "${{ matrix.config.testenvs }}" - name: "Upload Coverage πŸš€" uses: actions/upload-artifact@v2 - if: ${{ always() }} + if: ${{ always() && steps.setup-python.outcome == 'success' }} with: name: "coverage-${{ matrix.config.python-version }}" path: .coverage diff --git a/.github/workflows/python_ci_linux.yml b/.github/workflows/python_ci_linux.yml index 6c82ed24..d5177b22 100644 --- a/.github/workflows/python_ci_linux.yml +++ b/.github/workflows/python_ci_linux.yml @@ -5,13 +5,17 @@ name: Linux on: push: +permissions: + actions: write + contents: read + jobs: tests: name: "ubuntu-20.04 / Python ${{ matrix.config.python-version }}" runs-on: "ubuntu-20.04" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.6,pypy-3.6,pypy-3.7' + USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-beta.1,pypy-3.6,pypy-3.7' strategy: fail-fast: False @@ -21,7 +25,7 @@ jobs: - {python-version: "3.7", testenvs: "py37,build", experimental: False} - {python-version: "3.8", testenvs: "py38,build", experimental: False} - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.6", testenvs: "py310-dev,build", experimental: True} + - {python-version: "3.10.0-beta.1", testenvs: "py310-dev,build", experimental: True} - {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False} - {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: True} @@ -29,12 +33,25 @@ jobs: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v2" + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' + - name: Setup Python 🐍 + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} uses: "actions/setup-python@v2" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies πŸ”§ + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site @@ -43,11 +60,12 @@ jobs: python -m pip install --upgrade coverage_pyver_pragma - name: "Run Tests for Python ${{ matrix.config.python-version }}" + if: steps.setup-python.outcome == 'success' run: python -m tox -e "${{ matrix.config.testenvs }}" - name: "Upload Coverage πŸš€" uses: actions/upload-artifact@v2 - if: ${{ always() }} + if: ${{ always() && steps.setup-python.outcome == 'success' }} with: name: "coverage-${{ matrix.config.python-version }}" path: .coverage diff --git a/.github/workflows/python_ci_macos.yml b/.github/workflows/python_ci_macos.yml index e9e2bc12..68f5d34a 100644 --- a/.github/workflows/python_ci_macos.yml +++ b/.github/workflows/python_ci_macos.yml @@ -5,13 +5,17 @@ name: macOS on: push: +permissions: + actions: write + contents: read + jobs: tests: name: "macos-latest / Python ${{ matrix.config.python-version }}" runs-on: "macos-latest" continue-on-error: ${{ matrix.config.experimental }} env: - USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-alpha.6,pypy-3.6,pypy-3.7' + USING_COVERAGE: '3.6,3.7,3.8,3.9,3.10.0-beta.1,pypy-3.6,pypy-3.7' strategy: fail-fast: False @@ -21,7 +25,7 @@ jobs: - {python-version: "3.7", testenvs: "py37,build", experimental: False} - {python-version: "3.8", testenvs: "py38,build", experimental: False} - {python-version: "3.9", testenvs: "py39,build", experimental: False} - - {python-version: "3.10.0-alpha.6", testenvs: "py310-dev,build", experimental: True} + - {python-version: "3.10.0-beta.1", testenvs: "py310-dev,build", experimental: True} - {python-version: "pypy-3.6", testenvs: "pypy36,build", experimental: False} - {python-version: "pypy-3.7", testenvs: "pypy37,build", experimental: True} @@ -29,12 +33,25 @@ jobs: - name: Checkout πŸ›ŽοΈ uses: "actions/checkout@v2" + - name: Check for changed files + if: startsWith(github.ref, 'refs/tags/') != true + uses: dorny/paths-filter@v2 + id: changes + with: + list-files: "json" + filters: | + code: + - '!(doc-source/**|CONTRIBUTING.rst|.imgbotconfig|.pre-commit-config.yaml|.pylintrc|.readthedocs.yml)' + - name: Setup Python 🐍 + id: setup-python + if: ${{ steps.changes.outputs.code == 'true' || steps.changes.outcome == 'skipped' }} uses: "actions/setup-python@v2" with: python-version: "${{ matrix.config.python-version }}" - name: Install dependencies πŸ”§ + if: steps.setup-python.outcome == 'success' run: | python -VV python -m site @@ -42,11 +59,12 @@ jobs: python -m pip install --upgrade tox virtualenv - name: "Run Tests for Python ${{ matrix.config.python-version }}" + if: steps.setup-python.outcome == 'success' run: python -m tox -e "${{ matrix.config.testenvs }}" - name: "Upload Coverage πŸš€" uses: actions/upload-artifact@v2 - if: ${{ always() }} + if: ${{ always() && steps.setup-python.outcome == 'success' }} with: name: "coverage-${{ matrix.config.python-version }}" path: .coverage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f785a51..bca78c41 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,7 +62,7 @@ repos: - --keep-runtime-typing - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.9 + rev: v1.1.10 hooks: - id: remove-crlf - id: forbid-crlf diff --git a/doc-source/conf.py b/doc-source/conf.py index d77593fa..110b4ef9 100644 --- a/doc-source/conf.py +++ b/doc-source/conf.py @@ -7,67 +7,32 @@ import re import sys -sys.path.append(os.path.abspath('.')) -sys.path.append(os.path.abspath("..")) - # 3rd party import domdf_python_tools -# this package -from __pkginfo__ import __version__ - domdf_python_tools.__docs = True -github_username = "domdfcoding" -github_repository = "domdf_python_tools" -github_url = f"https://github.com/%7Bgithub_username%7D/%7Bgithub_repository%7D" +# 3rd party +from sphinx_pyproject import SphinxConfig + +sys.path.append('.') + +config = SphinxConfig(globalns=globals()) +project = config["project"] +author = config["author"] +documentation_summary = config.description + +github_url = "https://github.com/%7Bgithub_username%7D/%7Bgithub_repository%7D".format_map(config) rst_prolog = f""".. |pkgname| replace:: domdf_python_tools .. |pkgname2| replace:: ``domdf_python_tools`` .. |browse_github| replace:: `Browse the GitHub Repository <{github_url}>`__ """ -author = "Dominic Davis-Foster" -project = "domdf_python_tools".replace('_', '-') slug = re.sub(r'\W+', '-', project.lower()) -release = version = __version__ -copyright = "2019-2021 Dominic Davis-Foster" # pylint: disable=redefined-builtin -language = "en" -package_root = "domdf_python_tools" - -extensions = [ - "sphinx_toolbox", - "sphinx_toolbox.more_autodoc", - "sphinx_toolbox.more_autosummary", - "sphinx_toolbox.documentation_summary", - "sphinx_toolbox.tweaks.param_dash", - "sphinx_toolbox.tweaks.latex_toc", - "sphinx.ext.intersphinx", - "sphinx.ext.mathjax", - "sphinxcontrib.httpdomain", - "sphinxcontrib.extras_require", - "sphinx.ext.todo", - "sphinxemoji.sphinxemoji", - "notfound.extension", - "sphinx_copybutton", - "sphinxcontrib.default_values", - "sphinxcontrib.toctree_plus", - "sphinx_debuginfo", - "seed_intersphinx_mapping", - "sphinx_autofixture", - "sphinx_highlights", - ] - -sphinxemoji_style = "twemoji" -todo_include_todos = bool(os.environ.get("SHOW_TODOS", 0)) -gitstamp_fmt = "%d %b %Y" +release = version = config.version -templates_path = ["_templates"] -html_static_path = ["_static"] -source_suffix = ".rst" -master_doc = "index" -suppress_warnings = ["image.nonlocal_uri"] -pygments_style = "default" +todo_include_todos = bool(os.environ.get("SHOW_TODOS", 0)) intersphinx_mapping = { "python": ("https://docs.python.org/3/", None), @@ -78,10 +43,7 @@ "pytest-regressions": ("https://pytest-regressions.readthedocs.io/en/latest/", None), } -html_theme = "domdf_sphinx_theme" html_theme_options = {"logo_only": False} -html_theme_path = ["../.."] -html_show_sourcelink = True # True will show link to source html_context = { "display_github": True, @@ -96,53 +58,18 @@ man_pages = [("index", slug, project, [author], 1)] texinfo_documents = [("index", slug, project, author, slug, project, "Miscellaneous")] -toctree_plus_types = { - "class", - "function", - "method", - "data", - "enum", - "flag", - "confval", - "directive", - "role", - "confval", - "protocol", - "typeddict", - "namedtuple", - "exception", - } +toctree_plus_types = set(config["toctree_plus_types"]) -add_module_names = False -hide_none_rtype = True -all_typevars = True -overloads_location = "bottom" -documentation_summary = "Helpful functions for Pythonβ€‚πŸβ€‚πŸ› οΈ" - -autodoc_exclude_members = [ # Exclude "standard" methods. - "__dict__", - "__class__", - "__dir__", - "__weakref__", - "__module__", - "__annotations__", - "__orig_bases__", - "__parameters__", - "__subclasshook__", - "__init_subclass__", - "__attrs_attrs__", - "__init__", - "__new__", - "__getnewargs__", - "__abstractmethods__", - "__hash__", - ] autodoc_default_options = { "members": None, # Include all members (methods). "special-members": None, "autosummary": None, "show-inheritance": None, - "exclude-members": ','.join(autodoc_exclude_members), + "exclude-members": ','.join(config["autodoc_exclude_members"]), + } + +latex_elements = { + "fncychap": "\\usepackage[Bjarne]{fncychap}\n\\ChNameAsIs\n\\ChTitleAsIs\n", } manpages_url = "https://manpages.debian.org/%7Bpath%7D" diff --git a/pyproject.toml b/pyproject.toml index 331b2e13..cc4be4a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,3 +33,82 @@ all = [ "pytest>=6.2.0", "pytest-regressions>=2.0.2", "pytz>=2019.1",] conda-channels = [ "conda-forge", "domdfcoding",] extras = [ "dates",] license-key = "LGPL-3.0-or-later" + +[tool.sphinx-pyproject] +github_username = "domdfcoding" +github_repository = "domdf_python_tools" +author = "Dominic Davis-Foster" +project = "domdf-python-tools" +copyright = "2019-2021 Dominic Davis-Foster" +language = "en" +package_root = "domdf_python_tools" +extensions = [ + "sphinx_toolbox", + "sphinx_toolbox.more_autodoc", + "sphinx_toolbox.more_autosummary", + "sphinx_toolbox.documentation_summary", + "sphinx_toolbox.tweaks.param_dash", + "sphinx_toolbox.tweaks.latex_toc", + "sphinx.ext.intersphinx", + "sphinx.ext.mathjax", + "sphinxcontrib.httpdomain", + "sphinxcontrib.extras_require", + "sphinx.ext.todo", + "sphinxemoji.sphinxemoji", + "notfound.extension", + "sphinx_copybutton", + "sphinxcontrib.default_values", + "sphinxcontrib.toctree_plus", + "sphinx_debuginfo", + "seed_intersphinx_mapping", + "sphinx_autofixture", + "sphinx_highlights", +] +sphinxemoji_style = "twemoji" +gitstamp_fmt = "%d %b %Y" +templates_path = [ "_templates",] +html_static_path = [ "_static",] +source_suffix = ".rst" +master_doc = "index" +suppress_warnings = [ "image.nonlocal_uri",] +pygments_style = "default" +html_theme = "domdf_sphinx_theme" +html_theme_path = [ "../..",] +html_show_sourcelink = true +toctree_plus_types = [ + "class", + "confval", + "data", + "directive", + "enum", + "exception", + "flag", + "function", + "method", + "namedtuple", + "protocol", + "role", + "typeddict", +] +add_module_names = false +hide_none_rtype = true +all_typevars = true +overloads_location = "bottom" +autodoc_exclude_members = [ + "__dict__", + "__class__", + "__dir__", + "__weakref__", + "__module__", + "__annotations__", + "__orig_bases__", + "__parameters__", + "__subclasshook__", + "__init_subclass__", + "__attrs_attrs__", + "__init__", + "__new__", + "__getnewargs__", + "__abstractmethods__", + "__hash__", +] From 7c80cd80a84c4de2410406ba10d9410f6859c8b4 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 4 May 2021 22:16:10 +0100 Subject: [PATCH 5/8] Fix a final test with PyPy on Windows --- tests/test_paths_stdlib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_paths_stdlib.py b/tests/test_paths_stdlib.py index a001f457..85a15eb6 100644 --- a/tests/test_paths_stdlib.py +++ b/tests/test_paths_stdlib.py @@ -456,6 +456,10 @@ def my_mkdir(path, mode=0o777): assert (p.exists()) +@pytest.mark.skipif( + PYPY and sys.platform == "win32", + reason="symlink() is not implemented for PyPy on Windows", + ) def test_symlink_to(BASE): P = PathPlus(BASE) target = P / "fileA" From cc5feb5f14aba6384e47b584a406993bdcf9a897 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Tue, 4 May 2021 23:01:05 +0100 Subject: [PATCH 6/8] Sync config with master --- .bumpversion.cfg | 4 ++++ .pre-commit-config.yaml | 8 ++++---- .readthedocs.yml | 2 ++ README.rst | 10 +++------- __pkginfo__.py | 12 ------------ doc-source/conf.py | 5 +++++ doc-source/index.rst | 5 +---- doc-source/requirements.txt | 1 + pyproject.toml | 2 +- setup.cfg | 1 + setup.py | 4 ++++ tests/requirements.txt | 3 ++- tox.ini | 4 ++++ 13 files changed, 32 insertions(+), 29 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 32d195f0..50795a51 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -17,3 +17,7 @@ replace = : str = "{new_version}" [bumpversion:file:repo_helper.yml] [bumpversion:file:pyproject.toml] + +[bumpversion:file:setup.cfg] +search = version = {current_version} +replace = version = {new_version} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bca78c41..bc883899 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: args: - --allow-git - id: check-docstring-first - exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup|tests/.*)\.py$ + exclude: ^(doc-source/conf|__pkginfo__|setup|tests/.*)\.py$ - id: bind-requirements - repo: https://github.com/domdfcoding/flake8-dunder-all @@ -54,7 +54,7 @@ repos: - id: rst-inline-touching-normal - repo: https://github.com/asottile/pyupgrade - rev: v2.11.0 + rev: v2.12.0 hooks: - id: pyupgrade args: @@ -71,10 +71,10 @@ repos: rev: v0.4.3 hooks: - id: formate - exclude: ^(doc-source/conf|__pkginfo__|make_conda_recipe|setup)\.(_)?py$ + exclude: ^(doc-source/conf|__pkginfo__|setup)\.(_)?py$ - repo: https://github.com/domdfcoding/dep_checker - rev: v0.6.0 + rev: v0.6.2 hooks: - id: dep_checker args: diff --git a/.readthedocs.yml b/.readthedocs.yml index 41d2e576..6dfba21c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -15,3 +15,5 @@ python: - requirements: doc-source/requirements.txt - method: pip path: . + extra_requirements: + - all diff --git a/README.rst b/README.rst index 10c4c371..47802487 100644 --- a/README.rst +++ b/README.rst @@ -25,7 +25,7 @@ domdf_python_tools * - Activity - |commits-latest| |commits-since| |maintained| |pypi-downloads| * - QA - - |codefactor| |actions_flake8| |actions_mypy| |pre_commit_ci| + - |codefactor| |actions_flake8| |actions_mypy| * - Other - |license| |language| |requires| @@ -115,10 +115,6 @@ domdf_python_tools :target: https://pypi.org/project/domdf_python_tools/ :alt: PyPI - Downloads -.. |pre_commit_ci| image:: https://results.pre-commit.ci/badge/github/domdfcoding/domdf_python_tools/master.svg - :target: https://results.pre-commit.ci/latest/github/domdfcoding/domdf_python_tools/master - :alt: pre-commit.ci status - .. end shields @@ -143,8 +139,8 @@ To install with ``conda``: .. code-block:: bash - $ conda config --add channels http://conda.anaconda.org/conda-forge - $ conda config --add channels http://conda.anaconda.org/domdfcoding + $ conda config --add channels https://conda.anaconda.org/conda-forge + $ conda config --add channels https://conda.anaconda.org/domdfcoding * Then install diff --git a/__pkginfo__.py b/__pkginfo__.py index 7e9ec198..b76dfaf3 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -11,24 +11,12 @@ # This script based on https://github.com/rocky/python-uncompyle6/blob/master/__pkginfo__.py # -# stdlib -import pathlib - __all__ = [ - "__copyright__", "__version__", - "repo_root", - "install_requires", "extras_require", ] -__copyright__ = """ -2019-2021 Dominic Davis-Foster -""" - __version__ = "2.9.0" -repo_root = pathlib.Path(__file__).parent -install_requires = (repo_root / "requirements.txt").read_text(encoding="utf-8").split('\n') extras_require = { "dates": ["pytz>=2019.1"], "testing": ["pytest>=6.2.0", "pytest-regressions>=2.0.2"], diff --git a/doc-source/conf.py b/doc-source/conf.py index 110b4ef9..d0caecfc 100644 --- a/doc-source/conf.py +++ b/doc-source/conf.py @@ -22,6 +22,11 @@ author = config["author"] documentation_summary = config.description +# 3rd party +import domdf_python_tools + +domdf_python_tools.__docs = True + github_url = "https://github.com/%7Bgithub_username%7D/%7Bgithub_repository%7D".format_map(config) rst_prolog = f""".. |pkgname| replace:: domdf_python_tools diff --git a/doc-source/index.rst b/doc-source/index.rst index 5fa1b1e9..9d374e27 100644 --- a/doc-source/index.rst +++ b/doc-source/index.rst @@ -28,7 +28,7 @@ domdf_python_tools * - Activity - |commits-latest| |commits-since| |maintained| |pypi-downloads| * - QA - - |codefactor| |actions_flake8| |actions_mypy| |pre_commit_ci| + - |codefactor| |actions_flake8| |actions_mypy| * - Other - |license| |language| |requires| @@ -121,9 +121,6 @@ domdf_python_tools :downloads: month :alt: PyPI - Downloads - .. |pre_commit_ci| pre-commit-ci-shield:: - :alt: pre-commit.ci status - .. end shields diff --git a/doc-source/requirements.txt b/doc-source/requirements.txt index 21bbbb04..c9e6f6fa 100644 --- a/doc-source/requirements.txt +++ b/doc-source/requirements.txt @@ -14,6 +14,7 @@ sphinx-debuginfo>=0.1.0 sphinx-highlights>=0.1.0 sphinx-notfound-page>=0.5 sphinx-prompt>=1.1.0 +sphinx-pyproject>=0.1.0 sphinx-tabs>=1.1.13 sphinx-toolbox>=2.2.0 sphinxcontrib-httpdomain>=1.7.0 diff --git a/pyproject.toml b/pyproject.toml index cc4be4a2..80d2ce9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ keywords = [ "utilities",] dynamic = [ "requires-python", "classifiers", "dependencies",] [[project.authors]] -email = "dominic@davis-foster.co.uk" name = "Dominic Davis-Foster" +email = "dominic@davis-foster.co.uk" [project.license] diff --git a/setup.cfg b/setup.cfg index 12263955..c9d6b0ec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,6 +8,7 @@ [metadata] name = domdf_python_tools +version = 2.9.0 author = Dominic Davis-Foster author_email = dominic@davis-foster.co.uk license = GNU Lesser General Public License v3 or later (LGPLv3+) diff --git a/setup.py b/setup.py index dc275760..c0f03d20 100644 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ # This file is managed by 'repo_helper'. Don't edit it directly. # stdlib +import pathlib import shutil import sys @@ -13,6 +14,9 @@ # this package from __pkginfo__ import * # pylint: disable=wildcard-import +repo_root = pathlib.Path(__file__).parent +install_requires = (repo_root / "requirements.txt").read_text(encoding="UTF-8").split('\n') + setup( description="Helpful functions for Pythonβ€‚πŸβ€‚πŸ› οΈ", extras_require=extras_require, diff --git a/tests/requirements.txt b/tests/requirements.txt index 4f1ab343..4daaa2cd 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,11 +6,12 @@ coverage>=5.1 coverage-pyver-pragma>=0.2.1 faker>=4.1.2 flake8>=3.8.4 +importlib-metadata>=3.6.0 iniconfig!=1.1.0,>=1.0.1 pandas>=1.0.0; implementation_name == "cpython" and python_version < "3.10" pytest>=6.0.0 pytest-cov>=2.8.1 -pytest-randomly>=3.6.0 +pytest-randomly>=3.7.0 pytest-regressions>=2.0.1 pytest-rerunfailures>=9.1.1 pytest-timeout>=1.4.2 diff --git a/tox.ini b/tox.ini index 6b87f957..485ec77a 100644 --- a/tox.ini +++ b/tox.ini @@ -100,6 +100,10 @@ basepython = python3.6 skip_install = True ignore_errors = True whitelist_externals = /bin/bash +passenv = + COV_PYTHON_VERSION + COV_PLATFORM + COV_PYTHON_IMPLEMENTATION changedir = {toxinidir} deps = coverage>=5 From 0f9779ec5502b7590089264982b6de988e6fcafe Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Wed, 5 May 2021 07:08:44 +0100 Subject: [PATCH 7/8] Remove unused type: ignore comment --- domdf_python_tools/paths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/domdf_python_tools/paths.py b/domdf_python_tools/paths.py index 4b7bfe54..b4cba3e3 100644 --- a/domdf_python_tools/paths.py +++ b/domdf_python_tools/paths.py @@ -376,7 +376,7 @@ def __new__(cls, *args, **kwargs): # noqa D102 if cls is PathPlus: cls = WindowsPathPlus if os.name == "nt" else PosixPathPlus - self = cls._from_parts(args, init=False) # type: ignore + self = cls._from_parts(args, init=False) if not self._flavour.is_supported: raise NotImplementedError(f"cannot instantiate {cls.__name__!r} on your system") From f3faf226dfa10e5197bcd1b040963dc776aa3cd1 Mon Sep 17 00:00:00 2001 From: Dominic Davis-Foster Date: Wed, 5 May 2021 10:18:44 +0100 Subject: [PATCH 8/8] Bump version v2.9.0 -> v2.9.1 --- .bumpversion.cfg | 2 +- README.rst | 2 +- __pkginfo__.py | 2 +- doc-source/index.rst | 2 +- domdf_python_tools/__init__.py | 2 +- pyproject.toml | 2 +- repo_helper.yml | 2 +- setup.cfg | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 50795a51..a82d0522 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.9.0 +current_version = 2.9.1 commit = True tag = True diff --git a/README.rst b/README.rst index 47802487..75333445 100644 --- a/README.rst +++ b/README.rst @@ -100,7 +100,7 @@ domdf_python_tools .. |language| image:: https://img.shields.io/github/languages/top/domdfcoding/domdf_python_tools :alt: GitHub top language -.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/domdf_python_tools/v2.9.0 +.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/domdf_python_tools/v2.9.1 :target: https://github.com/domdfcoding/domdf_python_tools/pulse :alt: GitHub commits since tagged version diff --git a/__pkginfo__.py b/__pkginfo__.py index b76dfaf3..e2b855bf 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -16,7 +16,7 @@ "extras_require", ] -__version__ = "2.9.0" +__version__ = "2.9.1" extras_require = { "dates": ["pytz>=2019.1"], "testing": ["pytest>=6.2.0", "pytest-regressions>=2.0.2"], diff --git a/doc-source/index.rst b/doc-source/index.rst index 9d374e27..0c9fa175 100644 --- a/doc-source/index.rst +++ b/doc-source/index.rst @@ -106,7 +106,7 @@ domdf_python_tools :alt: GitHub top language .. |commits-since| github-shield:: - :commits-since: v2.9.0 + :commits-since: v2.9.1 :alt: GitHub commits since tagged version .. |commits-latest| github-shield:: diff --git a/domdf_python_tools/__init__.py b/domdf_python_tools/__init__.py index 1857383f..95cd7296 100644 --- a/domdf_python_tools/__init__.py +++ b/domdf_python_tools/__init__.py @@ -26,7 +26,7 @@ __author__: str = "Dominic Davis-Foster" __copyright__: str = "2014-2020 Dominic Davis-Foster" __license__: str = "LGPLv3+" -__version__: str = "2.9.0" +__version__: str = "2.9.1" __email__: str = "dominic@davis-foster.co.uk" __docs = False diff --git a/pyproject.toml b/pyproject.toml index 80d2ce9b..3d68e8b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "domdf_python_tools" -version = "2.9.0" +version = "2.9.1" description = "Helpful functions for Pythonβ€‚πŸβ€‚πŸ› οΈ" readme = "README.rst" keywords = [ "utilities",] diff --git a/repo_helper.yml b/repo_helper.yml index 147099a7..230f57bc 100644 --- a/repo_helper.yml +++ b/repo_helper.yml @@ -3,7 +3,7 @@ modname: domdf_python_tools copyright_years: "2019-2021" author: "Dominic Davis-Foster" email: "dominic@davis-foster.co.uk" -version: "2.9.0" +version: "2.9.1" username: "domdfcoding" license: 'LGPLv3+' short_desc: 'Helpful functions for Pythonβ€‚πŸβ€‚πŸ› οΈ' diff --git a/setup.cfg b/setup.cfg index c9d6b0ec..acbba399 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,7 +8,7 @@ [metadata] name = domdf_python_tools -version = 2.9.0 +version = 2.9.1 author = Dominic Davis-Foster author_email = dominic@davis-foster.co.uk license = GNU Lesser General Public License v3 or later (LGPLv3+)