Skip to content

Commit

Permalink
Drop Python upper version bound and migrate dev tools to Ruff (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Oct 12, 2023
1 parent 6772c50 commit 6108b10
Show file tree
Hide file tree
Showing 24 changed files with 383 additions and 373 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
python-version: "3.11"
py: py311
- platform: ubuntu-latest
python-version: 3.12.0-rc.1
python-version: "3.12"
py: py312
- platform: macos-latest
python-version: 3.8
Expand All @@ -53,7 +53,7 @@ jobs:
python-version: "3.11"
py: py311
- platform: macos-latest
python-version: 3.12.0-rc.1
python-version: "3.12"
py: py312
- platform: windows-latest
python-version: 3.8
Expand All @@ -62,7 +62,7 @@ jobs:
python-version: "3.11"
py: py311
- platform: windows-latest
python-version: 3.12.0-rc.1
python-version: "3.12"
py: py312
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/
report.html
.coverage
.pytest_cache/
.ruff_cache/
htmlcov/
*.egg-info/
venv*/
Expand All @@ -15,6 +16,5 @@ venv*/
.vscode
.mypy_cache/
*.so
.flakeheaven_cache/

site/
70 changes: 6 additions & 64 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,24 @@ repos:
name: check-hooks-apply
- id: check-useless-excludes
name: check-useless-excludes
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
args:
- --py38-plus
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
name: trailing-whitespace
- id: end-of-file-fixer
name: end-of-file-fixer
- id: double-quote-string-fixer
name: double-quote-string-fixer
- id: debug-statements
name: debug-statements
- repo: https://github.com/asottile/add-trailing-comma
rev: v3.0.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.290
hooks:
- id: add-trailing-comma
name: add-trailing-comma
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.2
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort-src
alias: isort-src
files: ^src
args:
- --add-import
- from __future__ import annotations
- id: isort
name: isort-meta
alias: isort-meta
files: ^(docs|tests)
- repo: https://github.com/mondeja/mdpo
rev: v1.1.3
hooks:
Expand All @@ -88,10 +66,6 @@ repos:
rev: v1.32.0
hooks:
- id: yamllint
files: .+\.(yml|yaml)
args:
- -c
- .yamllint.yaml
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.8.1
hooks:
Expand All @@ -104,16 +78,6 @@ repos:
- id: editorconfig-checker
name: editorconfig-checker
alias: ec
- repo: https://github.com/myint/autoflake
rev: v2.2.0
hooks:
- id: autoflake
args:
- --in-place
- --remove-all-unused-imports
- --remove-unused-variables
- --remove-duplicate-keys
- --ignore-init-module-imports
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
Expand All @@ -132,25 +96,3 @@ repos:
args:
- --config
- .markdown-link-check.json
- repo: https://github.com/flakeheaven/flakeheaven
rev: 3.3.0
hooks:
- id: flakeheaven
additional_dependencies:
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-executable
- flake8-implicit-str-concat
- flake8-print
- flake8-printf-formatting
- flake8-pytest-style
- flake8-bugbear
- flake8-encodings
- flake8-no-pep420
- flake8-absolute-import
- flake8-slots
- flake8-unused-arguments
- dlint
- pysetenv
entry: pysetenv FLAKEHEAVEN_CACHE_TIMEOUT=0 flakeheaven lint
170 changes: 78 additions & 92 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "mkdocs-include-markdown-plugin"
version = "6.0.1"
version = "6.0.2"
description = "Mkdocs Markdown includer plugin."
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.8,<3.13"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
Expand Down Expand Up @@ -81,9 +81,7 @@ matrix.mkdocs.dependencies = [
{ value = "mkdocs==1.5.0", if = ["1.5.0"] },
{ value = "mkdocs==1.5.1", if = ["1.5.1"] },
]
matrix.cache.dependencies = [
{ value = "platformdirs", if = ["yes"] },
]
matrix.cache.dependencies = [{ value = "platformdirs", if = ["yes"] }]

[tool.hatch.envs.tests.scripts]
all = "coverage run -m pytest"
Expand All @@ -102,12 +100,9 @@ targets = [{ file = "pyproject.toml" }]
[tool.project-config]
cache = "2 days"
style = [
"gh://mondeja/project-config-styles@v4.3/base/pre-commit/md2po2md.json5",
"gh://mondeja/project-config-styles@v4.3/python/base.json5",
"gh://mondeja/project-config-styles@v4.3/python/single-quotes.json5",
"gh://mondeja/project-config-styles@v4.3/python/tests.json5",
"gh://mondeja/project-config-styles@v4.3/python/google-docstrings.json5",
"gh://mondeja/project-config-styles@v4.3/python/mypy.json5",
"gh://mondeja/project-config-styles@v5/base/pre-commit/md2po2md.json5",
"gh://mondeja/project-config-styles@v5/python/base.json5",
"gh://mondeja/project-config-styles@v5/python/mypy.json5",
]

[tool.coverage.run]
Expand All @@ -117,90 +112,87 @@ parallel = true
data_file = ".coverage/.coverage"

[tool.coverage.report]
exclude_lines = [
"def __repr__\\(",
"@(abc\\.)?abstractmethod",
]
exclude_lines = ["def __repr__\\(", "@(abc\\.)?abstractmethod"]
fail_under = 1

[tool.flakeheaven]
inline-quotes = "single"
max-line-length = 80
pytest-fixture-no-parentheses = true
pytest-parametrize-values-type = "tuple"
docstring-convention = "google"
unused-arguments-ignore-abstract-functions = true

[tool.flakeheaven.plugins]
pycodestyle = ["+*", "-W503"]
pyflakes = ["+*"]
pylint = ["+*"]
flake8-builtins = ["+*"]
flake8-comprehensions = ["+*"]
flake8-docstrings = ["+*", "-D107", "-D105"]
flake8-executable = ["+*"]
flake8-implicit-str-concat = ["+*"]
flake8-print = ["+*"]
flake8-printf-formatting = ["+*"]
flake8-pytest-style = ["+*"]
flake8-bugbear = ["+*"]
flake8-encodings = ["+*"]
flake8-no-pep420 = ["+*"]
flake8-absolute-import = ["+*"]
flake8-unused-arguments = ["+*"]
flake8-slots = ["+*"]
dlint = ["+*"]

[tool.flakeheaven.exceptions."tests/**"]
flake8-docstrings = [
"-D100",
"-D101",
"-D102",
"-D103",
"-D104",
"-D107",
"-D205",
"-D415"
[tool.ruff]
line-length = 80
target-version = "py38"
select = [
"W",
"B",
"E",
"I",
"F",
"A",
"D",
"G",
"Q",
"PL",
"UP",
"PT",
"C4",
"EXE",
"ISC",
"T20",
"INP",
"ARG",
"SIM",
"RET",
"FBT",
"ERA",
"T10",
"COM",
"SLOT",
]
flake8-no-pep420 = ["-INP001"]

[tool.flakeheaven.exceptions."setup.py"]
flake8-docstrings = ["-D205"]
flake8-no-pep420 = ["-INP001"]

[tool.flakeheaven.exceptions."src/mkdocs_include_markdown_plugin/plugin.py"]
flake8-docstrings = ["-D100", "-D101", "-D102"]
flake8-unused-arguments = ["-U100"]

[tool.isort]
lines_after_imports = 2
multi_line_output = 3
line_length = 79
use_parentheses = true
combine_as_imports = true
include_trailing_comma = true
remove_redundant_aliases = true
known_tests = "tests"
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"FIRSTPARTY",
"TESTS",
"LOCALFOLDER"
]
py_version = 38
extra_standard_library = [
"contextvars",
"dataclasses",
"importlib.resources",
"importlib.metadata",

[tool.ruff.pydocstyle]
convention = "google"

[tool.ruff.flake8-quotes]
inline-quotes = "single"
multiline-quotes = "single"

[tool.ruff.flake8-pytest-style]
fixture-parentheses = false
parametrize-values-type = "tuple"
parametrize-values-row-type = "tuple"

[tool.ruff.isort]
lines-after-imports = 2
combine-as-imports = true
force-wrap-aliases = true
known-local-folder = ["tests"]
required-imports = ["from __future__ import annotations"]
extra-standard-library = [
"zoneinfo",
"graphlib",
"tomllib",
"wsgiref.types"
]

[tool.ruff.per-file-ignores]
"tests/**" = [
"I002",
"D100",
"D101",
"D102",
"D103",
"D104",
"D107",
"D205",
"D415",
"INP001",
"PLR0913",
"PLR2004",
]
"setup.py" = ["D205", "INP001", "I002"]
"src/mkdocs_include_markdown_plugin/plugin.py" = [
"D100",
"D101",
"D102",
]

[tool.mypy]
strict = true
python_version = "3.11"
Expand All @@ -210,9 +202,3 @@ allow_any_generics = true
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# The next object is enough to build the wheel with mypyc, but just
# provides a ~10% performance improvement on Python < 3.11 (on Python3.11
# is even slower):
#[tool.hatch.build.targets.wheel.hooks.mypyc]
#dependencies = ["hatch-mypyc", "mkdocs", "typing_extensions"]
#exclude = ["plugin.py"]
1 change: 1 addition & 0 deletions src/mkdocs_include_markdown_plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Mkdocs Markdown plugin to include files."""
13 changes: 7 additions & 6 deletions src/mkdocs_include_markdown_plugin/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
class Cache:
"""Cache for arbitrary content, one file per entry."""

def __init__(self, cache_dir: str, expiration_seconds: int = 0):
def __init__( # noqa: D107
self,
cache_dir: str,
expiration_seconds: int = 0,
):
self.cache_dir = cache_dir
self.expiration_seconds = expiration_seconds

Expand All @@ -46,11 +50,8 @@ def get_(self, url: str) -> str | None: # noqa: D102
creation_time = self.get_creation_time_from_fpath(fpath)
if time.time() < creation_time + self.expiration_seconds:
return self.read_file(fpath)
else:
os.remove(fpath)
return None
else:
return None
os.remove(fpath)
return None

def set_(self, url: str, value: str) -> None: # noqa: D102
key = self.generate_unique_key_from_url(url)
Expand Down

0 comments on commit 6108b10

Please sign in to comment.