From e8e88b65432ede601507b99c0abab24c5b833a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Wed, 28 Dec 2022 08:09:09 -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 | 6 ++- .markdownlint.yaml | 8 ++++ .pre-commit-config.yaml | 50 ++++++++++++++++-------- docs/changelog.rst | 3 ++ docs/conf.py | 42 ++++---------------- docs/logo.svg | 34 +++++++++++++--- pyproject.toml | 73 +++++++++++++++++++++++++++++++---- setup.cfg | 77 ------------------------------------- setup.py | 5 --- tests/test_filelock.py | 14 ++++++- tox.ini | 27 ++++--------- whitelist.txt | 1 - 12 files changed, 168 insertions(+), 172 deletions(-) create mode 100644 .markdownlint.yaml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5816632..c66e43c 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -61,7 +61,9 @@ jobs: CI_RUN: "yes" DIFF_AGAINST: HEAD - 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 @@ -134,7 +136,7 @@ jobs: publish: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - needs: [ check, coverage ] + needs: [check, coverage] runs-on: ubuntu-22.04 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 831d52c..376ceb8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,47 +11,65 @@ 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.3.1 hooks: - id: pyupgrade - args: [ "--py36-plus" ] + args: ["--py37-plus"] - repo: https://github.com/PyCQA/isort - rev: v5.11.3 + rev: 5.11.4 hooks: - id: isort - repo: https://github.com/psf/black 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: - id: rst-backticks - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.2.0 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/tox-dev/tox-ini-fmt rev: "0.5.2" hooks: - id: tox-ini-fmt - args: [ "-p", "fix_lint" ] + args: ["-p", "fix"] - repo: https://github.com/PyCQA/flake8 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.3 - - 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@2.7.1 + - "@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/docs/changelog.rst b/docs/changelog.rst index 7ee9ffc..184ac91 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,5 +1,8 @@ Changelog ========= +v3.9.0 (2022-12-28) +------------------- +- Move build backend to ``hatchling`` :pr:`185 - by :user:`gaborbernat`. v3.8.1 (2022-12-04) ------------------- diff --git a/docs/conf.py b/docs/conf.py index 00adba8..8a8501d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,50 +4,22 @@ from filelock import __version__ -company = "tox-dev" -name = "filelock" -version = ".".join(__version__.split(".")[:2]) -release = __version__ +name, company = "filelock", "tox-dev" +version, release = ".".join(__version__.split(".")[:2]), __version__ copyright = f"2014-{date.today().year}, {company}" - extensions = [ "sphinx.ext.autodoc", "sphinx.ext.autosectionlabel", + "sphinx.ext.viewcode", "sphinx.ext.extlinks", "sphinx.ext.intersphinx", "sphinx_autodoc_typehints", ] - -templates_path = [] -unused_docs = [] -source_suffix = ".rst" -exclude_patterns = ["_build"] - -master_doc = "index" -pygments_style = "default" - -project = name -today_fmt = "%B %d, %Y" - html_theme = "furo" -html_favicon = "logo.svg" -html_logo = "logo.svg" -html_theme_options = { - "navigation_with_keys": True, -} -html_title = name -html_last_updated_fmt = datetime.now().isoformat() - -autoclass_content = "class" -autodoc_member_order = "bysource" -autodoc_default_options = { - "member-order": "bysource", - "undoc-members": True, - "show-inheritance": True, -} -autodoc_typehints = "none" -always_document_param_types = False -typehints_fully_qualified = True +html_title, html_last_updated_fmt = name, 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} autosectionlabel_prefix_document = True intersphinx_mapping = {"python": ("https://docs.python.org/3", None)} diff --git a/docs/logo.svg b/docs/logo.svg index 03adda8..01624b7 100644 --- a/docs/logo.svg +++ b/docs/logo.svg @@ -1,9 +1,31 @@ - - + + - - - - + + + + diff --git a/pyproject.toml b/pyproject.toml index 4075294..c0baeef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,74 @@ [build-system] -requires = [ - "setuptools>=65.6.3", - "setuptools_scm>=7.0.5", +build-backend = "hatchling.build" +requires = ["hatchling>=1.11.1", "hatch-vcs>=0.3"] + +[project] +name = "filelock" +description = "A platform independent file lock." +readme = "README.md" +license = "Unlicense" +maintainers = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }] +urls.Documentation = "https://py-filelock.readthedocs.io" +urls.Homepage = "https://github.com/tox-dev/py-filelock" +urls.Source = "https://github.com/tox-dev/py-filelock" +urls.Tracker = "https://github.com/tox-dev/py-filelock/issues" +requires-python = ">=3.7" +optional-dependencies.testing = [ + "covdefaults>=2.2.2", + "coverage>=7.0.1", + "pytest>=7.2", + "pytest-cov>=4", + "pytest-timeout>=2.1", +] +optional-dependencies.docs = ["furo>=2022.12.7", "sphinx>=5.3", "sphinx-autodoc-typehints>=1.19.5"] +keywords = ["application", "cache", "directory", "log", "user"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: The Unlicense (Unlicense)", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Internet", + "Topic :: Software Development :: Libraries", + "Topic :: System", ] -build-backend = 'setuptools.build_meta' +dynamic = ["version"] + +[tool.hatch] +build.hooks.vcs.version-file = "src/filelock/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"] +paths.other = [".", "*/py-filelock", "*\\py-filelock"] +report.fail_under = 76 +run.parallel = true +run.plugins = ["covdefaults"] [tool.black] line-length = 120 [tool.isort] -line_length = 120 profile = "black" -known_first_party = ["filelock", "tests"] +known_first_party = ["filelock"] + +[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.setuptools_scm] -write_to = "src/filelock/version.py" +[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 0b24002..0000000 --- a/setup.cfg +++ /dev/null @@ -1,77 +0,0 @@ -[metadata] -name = filelock -description = A platform independent file lock. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/tox-dev/py-filelock -author = Benedikt Schmitt -author_email = benedikt@benediktschmitt.de -license = Unlicense -license_file = LICENSE -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: The Unlicense (Unlicense) - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Internet - Topic :: Software Development :: Libraries - Topic :: System -download_url = https://github.com/tox-dev/py-filelock/archive/main.zip -project_urls = - Source=https://github.com/tox-dev/py-filelock - Tracker=https://github.com/tox-dev/py-filelock/issues - -[options] -packages = find: -python_requires = >=3.7 -package_dir = - =src -zip_safe = True - -[options.packages.find] -where = src - -[options.extras_require] -docs = - furo>=2022.9.29 - sphinx>=5.3 - sphinx-autodoc-typehints>=1.19.5 -testing = - covdefaults>=2.2.2 - coverage>=6.5 - pytest>=7.2 - pytest-cov>=4 - pytest-timeout>=2.1 - -[options.package_data] -filelock = py.typed - -[coverage:run] -plugins = covdefaults -parallel = true - -[coverage:paths] -src = - src - .tox/**/lib/python*/site-packages - .tox/pypy*/site-packages - .tox\*\Lib\site-packages\ - **/src - **\src -other = - . - **/py-filelock - **\py-filelock - -[coverage:report] -fail_under = 88 - -[coverage:html] -show_contexts = true -skip_covered = false - -[coverage:covdefaults] -subtract_omit = */.tox/* diff --git a/setup.py b/setup.py deleted file mode 100644 index a03590f..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - -setup() diff --git a/tests/test_filelock.py b/tests/test_filelock.py index 2b212a4..a6acfb8 100644 --- a/tests/test_filelock.py +++ b/tests/test_filelock.py @@ -14,7 +14,14 @@ import pytest from _pytest.logging import LogCaptureFixture -from filelock import BaseFileLock, FileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock +from filelock import ( + BaseFileLock, + FileLock, + SoftFileLock, + Timeout, + UnixFileLock, + WindowsFileLock, +) @pytest.mark.parametrize( @@ -29,7 +36,10 @@ ], ) def test_simple( - lock_type: type[BaseFileLock], path_type: type[str] | type[Path], tmp_path: Path, caplog: LogCaptureFixture + lock_type: type[BaseFileLock], + path_type: type[str] | type[Path], + tmp_path: Path, + caplog: LogCaptureFixture, ) -> None: caplog.set_level(logging.DEBUG) diff --git a/tox.ini b/tox.ini index e2b63c6..1b0dc05 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - fix_lint + fix py311 py310 py39 @@ -13,12 +13,11 @@ envlist = readme isolated_build = true skip_missing_interpreters = true -minversion = 3.21 +minversion = 4 [testenv] description = run tests with {basepython} passenv = - PIP_* PYTEST_* setenv = COVERAGE_FILE = {toxworkdir}{/}.coverage.{envname} @@ -27,20 +26,20 @@ extras = commands = pytest {tty:--color=yes} {posargs: \ --junitxml {toxworkdir}{/}junit.{envname}.xml --cov {envsitepackagesdir}{/}filelock --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 wheel_build_env = .pkg -[testenv:fix_lint] +[testenv:fix] description = format the code base to adhere to our styles, and complain about what we cannot do automatically passenv = * basepython = python3.10 skip_install = true deps = - pre-commit>=2.20 + pre-commit>=2.21 commands = pre-commit run --all-files --show-diff-on-failure python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))' @@ -64,8 +63,8 @@ setenv = skip_install = true deps = covdefaults>=2.2.2 - coverage>=6.5 - diff-cover>=7.2 + coverage[toml]>=7.0.1 + diff-cover>=7.3 extras = parallel_show_output = true commands = @@ -110,15 +109,3 @@ extras = commands = python -m pip list --format=columns python -c 'import sys; print(sys.executable)' - -[flake8] -max-complexity = 22 -max-line-length = 120 -noqa-require-code = true -dictionaries = en_US,python,technical,django - -[pep8] -max-line-length = 120 - -[pytest] -timeout = 120 diff --git a/whitelist.txt b/whitelist.txt index 5c8258b..e127de8 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -4,7 +4,6 @@ autosectionlabel caplog eacces extlinks -favicon filelock frameinfo fspath