Fix/ruff linting#19
Open
RaulSMS wants to merge 19 commits into
Open
Conversation
Use explicit re-export pattern (X as X) for public API symbols in __init__.py so ruff recognises them as intentional. Suppress F403 on wildcard imports that are part of the public API. Add noqa for exec-loaded __version__ in setup.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These functions referenced undefined names (on_message, pdus) and were never called. Removing them also drops the unused `time` import. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix E711: use `is None` / `is not None` instead of == / != comparisons. Fix E712: use truthiness directly instead of comparing to True/False. Fix F841: remove unused local variable assignments (dtfi, excinfo, ca). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a ruff lint job to CI that runs on Python 3.10 and enforces E and F rules. Configure target-version = py310 in setup.cfg so ruff aligns upgrade suggestions with the declared minimum Python version. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
khauersp
reviewed
Jun 18, 2026
khauersp
reviewed
Jun 18, 2026
khauersp
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, I'm a fan of using ruff here to help have some consistency going forward, just one minor suggestion we could consider
- setup.py: keep noqa comment and master's test exclusion from packages - test/test_ecu.py: use new test.helpers.feeder import path from directory restructure; drop unused j1939 import
Declare ruff as an installable dev dependency via pip install -e .[lint] so the lint toolchain is managed in one place. Update the CI lint job to install via the extra instead of a bare pip install ruff. Suggested-by: khauersp
khauersp
previously approved these changes
Jun 19, 2026
khauersp
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for adding the extras, I'll go ahead and approve but can you check out the line I flagged?
Ruff uses .toml file to get the settigns so actually the setup.cfg was doing anything
ruff check . --statistics 25 I001 [*] unsorted-imports 12 W292 [*] missing-newline-at-end-of-file 8 UP032 [*] f-string 3 UP034 [*] extraneous-parentheses 1 B007 [ ] unused-loop-control-variable 1 UP004 [*] useless-object-inheritance 1 UP009 [*] utf8-encoding-declaration
python -m pytest .
ImportError while loading conftest 'C:\00_Developer\GitHub\python-can-j1939\conftest.py'.
conftest.py:3: in <module>
from test.helpers.feeder import Feeder
test\helpers\feeder.py:6: in <module>
import j1939
j1939\__init__.py:4: in <module>
from .Dm14Server import * # noqa: F403
^^^^^^^^^^^^^^^^^^^^^^^^^
j1939\Dm14Server.py:19: in <module>
class DM14Server:
j1939\Dm14Server.py:179: in DM14Server
pgn: int = j1939.ParameterGroupNumber.PGN.DM15,
^^^^^^^^^^^^^^^^^^^^^^^^^^
E AttributeError: partially initialized module 'j1939' has no attribute 'ParameterGroupNumber' (most likely due to a circular import)
With a bit more buffer for CI runners
…axed CI-friendly assertions - test_timer_no_drift: changed from strict ±10ms interval validation to checking timer completes all 10 callbacks and avoids extreme outliers (>1s) - test_memory_access_event_latency: increased timeout from 50ms to 500ms to accommodate slow CI machine scheduler variance Both tests remain meaningful while being reliable on variable-load CI systems.
Owner
Author
|
Setting this PR to draft since it will conflict with #30 , we should merge that one first |
helps with pip install -e ".[test,lint]"
during the merge commit 4d1baec to update this branch to latest master I overlooked some already fixed errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #18
And also fix the
ruff check .warnings: