fix(lint): move module-level statements out of import blocks - #225
Open
Caldalis wants to merge 1 commit into
Open
fix(lint): move module-level statements out of import blocks#225Caldalis wants to merge 1 commit into
Caldalis wants to merge 1 commit into
Conversation
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.
Problem
Two module-level statements sit inside import blocks, which makes every import that follows them a module-level import after code (E402):
backend/app/core/agent_loop.py:62—logger = logging.getLogger(__name__)is placed mid-block, so the 9 imports after it are flagged.backend/app/api/skills.py:59—_CHANNEL_LABELS = {...}does the same for the 4 imports after it.backend/tests/test_channel_routing.pyalso has two f-strings with no placeholders (F541).All 15 were introduced in 008fff3.
Change
Move both statements below their import blocks and drop the
fprefix from the two constant URLs. No behaviour changes.Why this is safe
loggeris only used inagent_loop.py:837,_CHANNEL_LABELSonly inskills.py:256and:296.AgentLoop,create_skillandrouter.agent_cwis a hard-coded id throughouttest_channel_routing.py(see line 48), so the two f-strings were leftovers rather than a missing interpolation.loggeris moved rather than removed, since it has a real call site.Note on visibility
These findings do not all show up in a default
ruff check backendrun.[tool.ruff]currently sets onlyline-lengthandtarget-version, so the active rule set is whatever the installed ruff defaults to; on ruff 0.16.4 that is 413 rules and 1983 findings, and E402 is not among the enabled rules. The 13 E402 findings above are therefore invisible under the current configuration and only surface when the rule set is stated explicitly.Pinning that rule set is a separate concern and I am happy to open a follow-up for it; this PR only fixes the code. configuration and only surface when the rule set is stated explicitly.
Pinning that rule set is a separate concern and I am happy to open a follow-up for it; this PR only fixes the code.
Tests
Run on this branch:
ruff check backend --select E4,E7,E9,F,W— passes (was 15 errors)pytest backend/tests— 1997 passedpython -c "import app.core.agent_loop, app.api.skills"— both import cleanlyUI validation
Not applicable: no route, template or rendered output is affected.