-
Notifications
You must be signed in to change notification settings - Fork 1
Bump ruff #182
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
Bump ruff #182
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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ This project is a Copier template used to generate other copier templates. It is | |
| - When disabling a linting rule with an inline directive, provide a comment at the end of the line (or on the line above for tools that don't allow extra text after an inline directive) describing the reasoning for disabling the rule. | ||
| - Avoid telling the type checker what a type is rather than letting it prove it. This includes type assertions (`as SomeType` in TypeScript, `cast()` in Python) and variable annotations that override inference. Prefer approaches that let the type checker verify the type itself: `isinstance`/`instanceof` narrowing, restructuring code so the correct type flows naturally, or using discriminated unions. When there is genuinely no alternative, add a comment explaining why the workaround is necessary and why it is safe. | ||
| - Avoid `||` (TypeScript) or `or` (Python) in `if`/`elif` conditions, and avoid `x in ['a', 'b']`-style membership tests in implementation code — coverage tools treat these as a single branch, silently masking untested paths and producing false 100% branch coverage. Use separate `if`/`elif` branches instead so each condition is independently covered. | ||
| - When filtering logic combines multiple `and`-joined guards (e.g. a null check alongside a value check), prefer a loop with explicit `if`/`continue` branches over a single-line comprehension. A compound boolean filter on one line hides individual branches from line coverage — each guard condition should be its own statement so missing test cases are surfaced. | ||
|
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 | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: git ls-files AGENTS.mdRepository: LabAutomationAndScreening/copier-base-template Length of output: 194 🏁 Script executed: cat -n AGENTS.md | sed -n '1,120p'Repository: LabAutomationAndScreening/copier-base-template Length of output: 14555 🏁 Script executed: cat -n AGENTS.mdRepository: LabAutomationAndScreening/copier-base-template Length of output: 17407 🏁 Script executed: rg -n "branch coverage|line coverage|coverage" AGENTS.md .github package.json pyproject.toml jest.config.* vitest.config.* pytest.ini .coveragerc . -g '!node_modules' -g '!dist' -g '!build'Repository: LabAutomationAndScreening/copier-base-template Length of output: 24875 🏁 Script executed: cat -n .config/.coveragercRepository: LabAutomationAndScreening/copier-base-template Length of output: 1151 Use branch coverage terminology here. The repo’s coverage config uses branch coverage, so this guideline should say branch coverage rather than line coverage. 🤖 Prompt for AI Agents |
||
|
|
||
| ## Testing | ||
|
|
||
|
|
@@ -24,7 +25,6 @@ This project is a Copier template used to generate other copier templates. It is | |
| - Avoid magic values in comparisons in tests in all languages (like ruff rule PLR2004 specifies). Note: `1` and `0` are not magic numbers (according to PLR2004) | ||
| - Prefer using random values in tests rather than arbitrary ones (e.g. the faker library, uuids, random.randint) when possible. For enums, pick randomly rather than hardcoding one value. | ||
| - Avoid loops in tests — assert each item explicitly so failures pinpoint the exact element. When verifying a condition across all items in a collection, collect the violations into a list and assert it's empty (e.g., assert [x for x in items if bad_condition(x)] == []). | ||
| - When filtering logic combines multiple `and`-joined guards (e.g. a null check alongside a value check), prefer a loop with explicit `if`/`continue` branches over a single-line comprehension. A compound boolean filter on one line hides individual branches from line coverage — each guard condition should be its own statement so missing test cases are surfaced. | ||
| - When a test's final assertion is an absence (e.g., element is `null`, list is empty, modal is closed), include a prior presence assertion confirming the expected state existed before the action that removed it. A test whose only assertion is an absence check can pass vacuously if setup silently failed. | ||
| - When asserting a mock or spy was called with specific arguments, always constrain as tightly as possible. In order of preference: (1) assert called exactly once with those args (`assert_called_once_with` in Python, `toHaveBeenCalledExactlyOnceWith` in Vitest/Jest); (2) if multiple calls are expected, assert the total call count and use a positional or last-call assertion (`nthCalledWith`, `lastCalledWith` / `assert_has_calls` with `call_args_list[n]`); (3) plain "called with at any point" (`toHaveBeenCalledWith`, `assert_called_with`) is a last resort only when neither the call count nor the call order can reasonably be constrained. | ||
| - When asserting an exception is raised, verify the error message includes all key constructor arguments — not just one identifying field. This ensures the error message is fully populated and catches cases where arguments are swapped or missing. In Python: use the `match` parameter in `pytest.raises`. In TypeScript: use a regex or substring in `toThrow`, or catch and assert on error properties individually. | ||
|
|
||
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.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '35,55p;170,190p' .pre-commit-config.yamlRepository: LabAutomationAndScreening/copier-base-template
Length of output: 1575
🏁 Script executed:
Repository: LabAutomationAndScreening/copier-base-template
Length of output: 448
Replace both pre-commit rev pins
.pre-commit-config.yaml#L45:rev: bee27e3a4fd1ea2111cf90ab89cd076c870fce14 # frozen: v1.pre-commit-config.yaml#L181:rev: 6b63472e72e1a91ed8a2f6d483790dfb644fa1d3 # frozen: 0.37.4📍 Affects 1 file
.pre-commit-config.yaml#L45-L45(this comment).pre-commit-config.yaml#L181-L181🤖 Prompt for AI Agents