Repository navigation
Move function-level stdlib imports to the top of the file - #936
Open
mircealungu wants to merge 1 commit into
Open
mircealungu wants to merge 1 commit into
mircealungu wants to merge 1 commit into
Conversation
Also drops function-level imports that repeat a top-level one, and adds a test that keeps stdlib imports out of functions. article.py now uses one form of datetime. user.py keeps its three local datetime imports: its top-level `import datetime` means something else, and about 20 uses depend on that. Closes #935 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.



Closes #935.
What changed
zeeguu.*imports. (The issue's 119 matched by module; matching by exact name gives 62.)article.pynow uses one form ofdatetime, so its twoall_*_thanfunctions no longer need a local import. They had no test, so I added one.zeeguu/core/test/test_stdlib_imports_at_top.pyfails on a function-level stdlib import.The edits were scripted with an AST pass, which skips any import whose name means something else at the top of the file.
Left alone
user.py: three localfrom datetime import ...imports stay. The top-levelimport datetimeis the module, and about 20 uses depend on that. The check allows this kind of clash automatically, so there is no allowlist.Testing
import hashlibis put back.🤖 Generated with Claude Code