diff --git a/.docker/docker-compose.ci-test.yml b/.docker/docker-compose.ci-test.yml index c7b50d8..a273f14 100644 --- a/.docker/docker-compose.ci-test.yml +++ b/.docker/docker-compose.ci-test.yml @@ -1,6 +1,6 @@ # docker-compose file for running testing with Tika container # for a more end to end test of the Tika related functionality -# Can be used locally or by the CI to start the nessecary container with the +# Can be used locally or by the CI to start the necessary container with the # correct networking for the tests version: "3" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07d1065..e19aeb4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ repos: # General hooks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-docstring-first - id: check-json @@ -26,19 +26,28 @@ repos: - svg - id: check-case-conflict - id: detect-private-key - - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v3.1.0' + # See https://github.com/prettier/prettier/issues/15742 for the fork reason + - repo: https://github.com/rbubley/mirrors-prettier + rev: "v3.3.3" hooks: - id: prettier types_or: - javascript - ts - markdown + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell # Python hooks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.4.8' + rev: 'v0.6.9' hooks: # Run the linter. - id: ruff # Run the formatter. - id: ruff-format + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "2.2.4" + hooks: + - id: pyproject-fmt diff --git a/CHANGELOG.md b/CHANGELOG.md index afa73b4..61412db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.2 (by [@dependabot](https://github.com/apps/dependabot) in [#22](https://github.com/stumpylog/tika-client/pull/22)) +- Update `pre-commit` to 4.0.1 ([#23](https://github.com/stumpylog/tika-client/pull/23)) ## [0.6.0] - 2024-07-18 diff --git a/pyproject.toml b/pyproject.toml index 4082016..50621ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,29 @@ # # Project Configuration # + [build-system] -requires = ["hatchling"] build-backend = "hatchling.build" +requires = [ "hatchling" ] + [project] name = "tika-client" -dynamic = ["version"] description = "A modern REST client for Apache Tika server" readme = "README.md" -requires-python = ">=3.8" +keywords = [ "api", "client", "html", "office", "pdf", "tika" ] license = "MPL-2.0" -keywords = ["api", "pdf", "html", "client", "office", "tika"] authors = [ { name = "Trenton H", email = "rda0128ou@mozmail.com" }, ] +requires-python = ">=3.8" classifiers = [ "Development Status :: 4 - Beta", + "Environment :: Web Environment", + "Intended Audience :: Developers", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", - "Intended Audience :: Developers", - "Environment :: Web Environment", "Programming Language :: Python", - "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -33,28 +33,29 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", ] +dynamic = [ "version" ] dependencies = [ - "httpx ~= 0.27; python_version >= '3.9'", - "httpx ~= 0.24; python_version < '3.9'", - "typing-extensions; python_version < '3.11'" + "httpx~=0.24; python_version<'3.9'", + "httpx~=0.27; python_version>='3.9'", + "typing-extensions; python_version<'3.11'", ] -[project.urls] -Documentation = "https://github.com/stumpylog/tika-rest-client#readme" -Issues = "https://github.com/stumpylog/tika-rest-client/issues" -Source = "https://github.com/stumpylog/tika-rest-client" -Changelog = "https://github.com/stumpylog/tika-rest-client/blob/main/CHANGELOG.md" +urls.Changelog = "https://github.com/stumpylog/tika-rest-client/blob/main/CHANGELOG.md" # # Hatch Configuration # +urls.Documentation = "https://github.com/stumpylog/tika-rest-client#readme" +urls.Issues = "https://github.com/stumpylog/tika-rest-client/issues" +urls.Source = "https://github.com/stumpylog/tika-rest-client" + [tool.hatch.version] path = "src/tika_client/__about__.py" [tool.hatch.build.targets.sdist] exclude = [ ".github", - ".docker" + ".docker", ] [tool.hatch.envs.default] @@ -62,7 +63,7 @@ installer = "uv" [tool.hatch.envs.hatch-static-analysis] # https://hatch.pypa.io/latest/config/internal/static-analysis/ -dependencies = ["ruff ~= 0.5.6"] +dependencies = [ "ruff ~= 0.6" ] config-path = "none" [tool.hatch.envs.hatch-test] @@ -81,31 +82,32 @@ dependencies = [ ] extra-dependencies = [ "pytest-sugar", - "pytest-httpx ~= 0.30; python_version >= '3.9'", + "pytest-httpx == 0.30.0; python_version >= '3.9'", "pytest-httpx ~= 0.22; python_version < '3.9'", "python-magic", ] -extra-args = ["--maxprocesses=8", "--pythonwarnings=all"] +extra-args = [ "--maxprocesses=8", "--pythonwarnings=all" ] [tool.hatch.envs.hatch-test.scripts] run = [ "python3 --version", - "pytest{env:HATCH_TEST_ARGS:} {args}"] + "pytest{env:HATCH_TEST_ARGS:} {args}", +] run-cov = [ "python3 --version", "coverage erase", - "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}" + "coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}", ] -cov-combine = ["coverage combine"] +cov-combine = [ "coverage combine" ] cov-report = [ "coverage report", "coverage json", - "coverage html" + "coverage html", ] [[tool.hatch.envs.hatch-test.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10"] +python = [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10" ] # # Custom Environments @@ -113,40 +115,41 @@ python = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8", "pypy3.9", "pypy3.10" [tool.hatch.envs.typing] detached = true dependencies = [ - "mypy ~= 1.11.0", + "mypy ~= 1.11", "httpx", ] [tool.hatch.envs.typing.scripts] run = [ "mypy --version", - "mypy --install-types --non-interactive {args:src/tika_client}" + "mypy --install-types --non-interactive {args:src/tika_client}", ] [tool.hatch.envs.pre-commit] template = "pre-commit" detached = true dependencies = [ - "pre-commit ~= 3.8.0", + "pre-commit ~= 4.0", + "pre-commit-uv", ] [tool.hatch.envs.pre-commit.scripts] -check = ["pre-commit run --all-files"] -update = ["pre-commit autoupdate"] +check = [ "pre-commit run --all-files" ] +update = [ "pre-commit autoupdate" ] # # Tool Configuration # + [tool.ruff] -# https://docs.astral.sh/ruff/settings/ -fix = true -output-format = "grouped" target-version = "py38" line-length = 120 -[tool.ruff.lint] +# https://docs.astral.sh/ruff/settings/ +fix = true +output-format = "grouped" # https://docs.astral.sh/ruff/rules/ -extend-select = [ +lint.extend-select = [ "A", "ARG", "B", @@ -169,15 +172,15 @@ extend-select = [ "ISC", "N", "PERF", - "PIE", "PGH", - "PTH", + "PIE", "PL", "PLC", "PLE", "PLR", "PLW", "PT", + "PTH", "Q", "RSE", "RUF", @@ -195,38 +198,47 @@ extend-select = [ "W", "YTT", ] -ignore = [ +lint.ignore = [ # Allow non-abstract empty methods in abstract base classes "B027", + # Ignore complexity + "C901", # Allow boolean positional values in function calls, like `dict.get(... True)` "FBT003", + "PLR0911", + "PLR0912", + "PLR0913", + "PLR0915", # Ignore checks for possible passwords - "S105", "S106", "S107", - # Ignore complexity - "C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", + "S105", + "S106", + "S107", # Ignore no author and missing issue link in TODO tags - "TD002", "TD003" + "TD002", + "TD003", ] - -[tool.ruff.lint.isort] -force-single-line = true -known-first-party = ["tika_client"] - -[tool.ruff.lint.flake8-tidy-imports] -ban-relative-imports = "all" - -[tool.ruff.lint.per-file-ignores] # Tests can use magic values, assertions, and relative imports -"tests/**/*" = ["PLR2004", - "S101", - "TID252", - # Allow more complex pytest.raises - "PT012", - "DTZ001" - ] +lint.per-file-ignores."tests/**/*" = [ + "DTZ001", + "PLR2004", + # Allow more complex pytest.raises + "PT012", + "S101", + "TID252", +] +# No relative imports +lint.flake8-tidy-imports.ban-relative-imports = "all" +# One import per line +lint.isort.force-single-line = true +# Recognize us please +lint.isort.known-first-party = [ "tika_client" ] + +[tool.pytest.ini_options] +minversion = "7.0" +testpaths = [ "tests" ] [tool.coverage.run] -source_pkgs = ["tika_client", "tests"] +source_pkgs = [ "tika_client", "tests" ] branch = true parallel = true omit = [ @@ -234,8 +246,8 @@ omit = [ ] [tool.coverage.paths] -tika_client = ["src/tika_client", "*/tika-client/src/tika_client"] -tests = ["tests", "*/tika-client/tests"] +tika_client = [ "src/tika_client", "*/tika-client/src/tika_client" ] +tests = [ "tests", "*/tika-client/tests" ] [tool.coverage.report] exclude_lines = [ @@ -255,6 +267,3 @@ warn_redundant_casts = true warn_unused_ignores = true warn_unreachable = true warn_unused_configs = true - -[tool.pytest.ini_options] -minversion = "7.0" diff --git a/tests/conftest.py b/tests/conftest.py index d0bf901..f52a47c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,13 +12,13 @@ SAMPLE_DIR: Final[Path] = Path(__file__).parent.resolve() / "samples" -@pytest.fixture() +@pytest.fixture def tika_client() -> TikaClient: with TikaClient(tika_url=TIKA_URL, log_level=logging.INFO) as client: yield client -@pytest.fixture() +@pytest.fixture def tika_client_compressed() -> TikaClient: with TikaClient(tika_url=TIKA_URL, log_level=logging.INFO, compress=True) as client: yield client