Repository navigation
Copier update: more pyrefly rules #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ repos: | |
|
|
||
| # Reformatting (should generally come before any file format or other checks, because reformatting can change things) | ||
| - repo: https://github.com/crate-ci/typos | ||
| rev: 96d9af6217dc2855210655af7e1ff19d23d4e593 # frozen: v1 | ||
| rev: 12ffd4a04b4893ab75db66a59aaad2d996c3e982 # frozen: v1 | ||
| hooks: | ||
| - id: typos | ||
| args: [--write-changes, --force-exclude, --config, .config/_typos.toml] | ||
|
|
@@ -84,19 +84,6 @@ repos: | |
| .*\.svg| | ||
| .*/vendor_files/.*| | ||
| )$ | ||
| - id: pretty-format-json | ||
| exclude: | | ||
| (?x)^( | ||
| .devcontainer/devcontainer.json| | ||
| .devcontainer/devcontainer-lock.json| | ||
| .*devcontainer.json| | ||
| .*tsconfig.json| | ||
| .*biome.jsonc| | ||
| .*/generated/open[-_]api/.*| | ||
| .*tests/.*/__snapshots__/.*| | ||
| .*/vendor_files/.*| | ||
| )$ | ||
| args: [--autofix, --no-sort-keys] | ||
|
|
||
| - repo: https://github.com/biomejs/pre-commit | ||
| rev: a450e9c04887b1305951c298db5999cd30155f74 # frozen: v2.1.1 | ||
|
|
@@ -111,7 +98,7 @@ repos: | |
| )$ | ||
|
|
||
| - repo: https://github.com/rbubley/mirrors-prettier | ||
| rev: 9337a74165b178ae2c766f60bee7252a0f06f3e8 # frozen: v3.9.5 | ||
| rev: 0ee178619d696787ca73d210cc191d720868c631 # frozen: v3.9.6 | ||
| hooks: | ||
| - id: prettier | ||
| args: [--config, .config/.prettierrc] | ||
|
|
@@ -181,7 +168,7 @@ repos: | |
| - id: check-case-conflict | ||
|
|
||
| - repo: https://github.com/python-jsonschema/check-jsonschema | ||
| rev: 1a4bb160cab6417b3045e1b37b6b72449243e658 # frozen: 0.37.4 | ||
| rev: c4654a7e007c9619a5eb63c39a456572a0fa1851 # frozen: 0.38.0 | ||
| hooks: | ||
| - id: check-github-workflows | ||
|
|
||
|
|
@@ -226,18 +213,18 @@ repos: | |
| exclude: docs/.*\.rst$ | ||
|
|
||
| - repo: https://github.com/hadolint/hadolint | ||
| rev: 4e697ba704fd23b2409b947a319c19c3ee54d24f # frozen: v2.14.0 | ||
| rev: 2eece55955ced00200be9729e9728cb7dacca505 # frozen: v2.15.1 | ||
| hooks: | ||
| - id: hadolint-docker | ||
| name: Lint Dockerfiles | ||
| # The hadolint pre-commit has a problem where it just always pulls the `latest` image at runtime. | ||
| # Explicitly pinning the image here to the same rev as the hook to patch it until https://github.com/hadolint/hadolint/pull/1177 gets resolved. | ||
| entry: ghcr.io/hadolint/hadolint:v2.14.0@sha256:27086352fd5e1907ea2b934eb1023f217c5ae087992eb59fde121dce9c9ff21e hadolint | ||
| entry: ghcr.io/hadolint/hadolint:v2.15.1@sha256:fdf19d026b54834f88c62774fdf2a61ff3b586a42632e5070674d41a796bfdf3 hadolint | ||
| exclude: .*\.jinja$ | ||
| description: Runs hadolint to lint Dockerfiles | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: 2700fd5671c633760d912769c041bfcde2b9a01b # frozen: v0.15.22 | ||
| rev: 65dbdb59d2f2d9c3bdc343c566821ad3319ddaa3 # frozen: v0.16.3 | ||
| hooks: | ||
| - id: ruff | ||
| name: ruff-src | ||
|
|
@@ -268,15 +255,18 @@ repos: | |
| )$ | ||
|
|
||
| - repo: https://github.com/pylint-dev/pylint | ||
| rev: 8a396357098337ba8be714fffdf2d00947a9778c # frozen: v4.0.6 | ||
| rev: f5a6e3b1de17502747a40d7f92f285ccf9c6c459 # frozen: v4.0.7 | ||
| hooks: | ||
| - id: pylint | ||
| name: pylint | ||
| # exclude any generated code | ||
| # flagging duplicate code for __all__ lists is a false positive | ||
| # exclude the template files---duplication within them will be discovered during CI of that template instantiation | ||
| exclude: | | ||
| (?x)^( | ||
| .*/generated/graphql/.*| | ||
| .*/generated/open[-_]api/.*| | ||
| .*__init__\.py| | ||
|
Comment on lines
+262
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- relevant configuration ---'
sed -n '230,285p' .pre-commit-config.yaml
printf '%s\n' '--- Pylint configuration references ---'
rg -n --hidden --glob '!/.git/**' '^\s*\[.*pylint|disable\s*=|duplicate-code|pylint' \
.pre-commit-config.yaml pyproject.toml setup.cfg tox.ini .pylintrc 2>/dev/null || true
printf '%s\n' '--- initializer files tracked in the repository ---'
git ls-files '*__init__.py' | sed -n '1,120p'Repository: LabAutomationAndScreening/copier-python-package-template Length of output: 2526 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- Pylint configuration ---'
sed -n '1,240p' .config/pylintrc.toml
printf '%s\n' '--- pre-commit exclusion behavior for tracked Python files ---'
python3 - <<'PY'
import pathlib
import re
config = pathlib.Path(".pre-commit-config.yaml").read_text()
start = config.index(" - id: pylint")
end = config.index("\n - repo:", start)
block = config[start:end]
match = re.search(r"exclude:\s*\|\n(?P<body>(?:\s{10,}.*\n)+)", block)
if not match:
raise SystemExit("Could not extract the Pylint exclude pattern")
pattern = "\n".join(line[10:] for line in match.group("body").splitlines())
compiled = re.compile(pattern, re.X)
for path in pathlib.Path(".").rglob("*.py"):
rel = path.as_posix().removeprefix("./")
if rel.endswith("__init__.py"):
print(f"{rel}: excluded={bool(compiled.search(rel))}")
PYRepository: LabAutomationAndScreening/copier-python-package-template Length of output: 2120 🌐 Web query:
💡 Result: To manage Pylint analysis behavior effectively, especially when using pre-commit, you should combine Pylint's internal message controls with pre-commit's file-exclusion mechanisms. Message Control Pylint allows you to selectively enable and disable checks using command-line arguments, configuration files (like.pylintrc or pyproject.toml), or inline pragmas [1][2][3]. - Disabling everything and enabling only critical messages: You can use --disable=all followed by --enable=fatal,astroid-error to focus only on severe issues [2]. Note that syntax-error is handled by Astroid during parsing and is generally raised as an exception rather than emitted as a standard, suppressible Pylint message [4][5]. - Inline Pragma: To control messages within code, use # pylint: disable= or # pylint: enable= [1][3]. - Ignoring files: The # pylint: skip-file pragma at the top of a file tells Pylint to ignore that file entirely [6][3]. Pre-commit Exclusions When Pylint is invoked via pre-commit, it receives an explicit list of files [7][8]. Pylint's internal --ignore and --ignore-paths settings are primarily designed for directory recursion and may be bypassed when files are explicitly provided via the command line [7][8]. To reliably exclude files or directories in a pre-commit environment, use the exclude option directly in your.pre-commit-config.yaml hook definition [7][8]: - name: pylint entry: pylint language: system types: [python] exclude: ^path/to/ignore/|path/to/other/file.py$ Because Pylint often requires full context to perform accurate inference, it is generally recommended to set require_serial: true in your pre-commit hook configuration [9]. This ensures Pylint analyzes your project with complete visibility, avoiding issues caused by slicing files into smaller, isolated batches [9]. Citations:
Narrow the Pylint exclusion to specific files. The current pattern skips every 🤖 Prompt for AI Agents |
||
| template/.*| | ||
| )$ | ||
| args: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a reason for the inline suppression.
# spellchecker:disable-linedisables the spellchecker without explaining why the suppression is safe. Add a short reason in the syntax accepted by the configured spellchecker, such as noting thatastroid-erroris a Pylint message identifier.As per coding guidelines, inline suppression directives must include a reason.
🤖 Prompt for AI Agents
Source: Coding guidelines