Skip to content

Commit

Permalink
chore: update lints
Browse files Browse the repository at this point in the history
Signed-off-by: JP-Ellis <josh@jpellis.me>
  • Loading branch information
JP-Ellis committed Nov 19, 2024
1 parent 4443840 commit e4bfcdd
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 48 deletions.
55 changes: 39 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
default_install_hook_types:
- commit-msg
- pre-commit
Expand All @@ -10,7 +11,7 @@ default_stages:
repos:
# Generic hooks that apply to a lot of files
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -26,7 +27,11 @@ repos:
# modify the formatting.
- id: check-toml
- id: check-xml
- id: check-yaml

- repo: https://github.com/lyz-code/yamlfix/
rev: 1.17.0
hooks:
- id: yamlfix

- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
Expand All @@ -35,27 +40,26 @@ repos:
# allows for comments within JSON files.
- id: check-json5

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
- repo: https://github.com/biomejs/pre-commit
rev: v0.5.0
hooks:
- id: prettier
exclude: |
(?x)^(
src/pypacter/.*\.md
)$
- id: biome-check
additional_dependencies:
- '@biomejs/biome@1.9.4'

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args:
- --fix
- --exit-non-zero-on-fix
- id: ruff-format

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.31.0
- repo: https://github.com/crate-ci/committed
rev: v1.1.1
hooks:
- id: commitizen
stages: [commit-msg]
- id: committed

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
Expand All @@ -66,6 +70,23 @@ repos:
src/pypacter/.*\.md
)
- repo: https://github.com/crate-ci/typos
rev: v1.27.3
hooks:
- id: typos

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args:
- --external-sources

- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.9.0-1
hooks:
- id: shfmt

- repo: local
hooks:
# Mypy is difficult to run in pre-commit's isolated environment as it
Expand All @@ -74,5 +95,7 @@ repos:
name: mypy
entry: hatch run mypy
language: system
types: [python]
stages: [pre-push]
types:
- python
stages:
- pre-push
22 changes: 22 additions & 0 deletions committed.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Configuration for committed
##
## See <https://github.com/crate-ci/committed/blob/master/docs/reference.md>
allowed_types = [
"fix",
"feat",
"chore",
"docs",
"style",
"refactor",
"perf",
"test",
"release",
]

line_length = 80
merge_commit = false
no_fixup = false
style = "conventional"
subject_capitalized = false

ignore_author_re = "(?i)dependabot|renovate(( |-)bot)?"
81 changes: 49 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Code Generators",
]

requires-python = ">=3.8"
requires-python = ">=3.12"

dependencies = ["langchain_openai~=0.0.0", "langchain~=0.3.7", "pyyaml~=6.0"]

Expand Down Expand Up @@ -56,54 +57,46 @@ source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "src/pypacter/__version__.py"

[tool.hatch.build.targets.sdist]
include = [
# Source
"/src/pypacter/**/*.py",
"/src/pypacter/**/*.pyi",
"/src/pypacter/py.typed",
]

[tool.hatch.build.targets.wheel]
packages = ["/src/pypacter"]
include = [
# Source
"/src/pypacter/**/*.py",
"/src/pypacter/**/*.pyi",
"/src/pypacter/py.typed",
]

[tool.hatch.envs.default]
installer = "uv"
python = "3.12"
features = ["devel"]
pre-install-commands = [
"pip install -q --disable-pip-version-check --no-deps --editable {root:uri}/pypacter-api[devel]",
]
# This is require to get around an incompatibility between hatch and uv
# See: https://github.com/pypa/hatch/issues/1639
pre-install-commands = ["uv pip install .[devel]"]

[tool.hatch.envs.default.scripts]
lint = "ruff check --show-source --show-fixes {args} src tests"
typecheck = "mypy src tests {args}"
format = "ruff format src tests {args}"
lint = "ruff check --output-format full --show-fixes {args} src tests"
typecheck = "mypy . {args}"
format = "ruff format . {args}"
test = "pytest tests/ {args}"
test-all = "pytest tests/ pypacter-api/tests/ {args}"
all = ["format", "lint", "typecheck", "test"]

[tool.hatch.envs.test]
installer = "uv"
features = ["devel"]
pre-install-commands = [
"pip install -q --disable-pip-version-check --no-deps --editable {root:uri}/pypacter-api[devel]",
]
# This is require to get around an incompatibility between hatch and uv
# See: https://github.com/pypa/hatch/issues/1639
pre-install-commands = ["uv pip install .[devel-test]"]

[[tool.hatch.envs.test.matrix]]
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
python = ["3.12", "3.13"]

################################################################################
## UV Configuration
################################################################################
[tool.uv.workspace]
members = ["pypacter-api"]

[tool.uv.sources]
pypacter = { workspace = true }
pypacter-api = { workspace = true }

################################################################################
## Ruff Configuration
################################################################################

[tool.ruff]
target-version = "py311"

[tool.ruff.lint]
select = ["ALL"]
Expand All @@ -130,6 +123,13 @@ known-first-party = ["pypacter", "pypacter_api"]

[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"
banned-module-level-imports = [
# Use Pydantic V2 instead
"pydantic.v1",
]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"pydantic.v1".msg = "Use Pydantic V2 instead"

[tool.ruff.lint.pydocstyle]
convention = "google"
Expand All @@ -147,6 +147,7 @@ addopts = [
"--cov-config=pyproject.toml",
"--cov-report=xml",
]
asyncio_default_fixture_loop_scope = "function"

################################################################################
## Mypy Configuration
Expand All @@ -160,7 +161,7 @@ plugins = "pydantic.mypy"
################################################################################

[tool.coverage.paths]
pypacter = ["/src/pypacter"]
pypacter = ["src/pypacter"]
tests = ["tests"]

[tool.coverage.report]
Expand All @@ -170,3 +171,19 @@ exclude_lines = [
"raise NotImplementedError", # Ignore defensive assertions
"@(abc\\.)?abstractmethod", # Ignore abstract methods
]

################################################################################
## Typos
################################################################################

[tool.typos.default]
extend-ignore-re = ["(?Rm)^.*(#|//)\\s*spellchecker:ignore$"]

################################################################################
## Yamlfix
################################################################################
[tool.yamlfix]
line_length = 100
whitelines = 1
section_whitelines = 1
sequence_style = "block_style"

0 comments on commit e4bfcdd

Please sign in to comment.