[issue38297] Imports at top of module is often not used

2019-10-01 Thread Christian Heimes
Christian Heimes added the comment: A considerable amount of code is a lot older than PEP 8, some even over a decade older. Even newer code in the stdlib does not conform to PEP 8 for multiple reasons, e.g. external modules was incorporated into the stdlib. PEP 8 sections "Introduction" and

[issue38297] Imports at top of module is often not used

2019-10-01 Thread Dominic Littlewood
Dominic Littlewood <11dlittlew...@gmail.com> added the comment: With all due respect, I disagree with what you're saying here. "It's a bit misleading to use the stdlib as a guideline" ... when looking at the style guide for the stdlib? I appreciate that PEP 8 is used for other purposes, but it

[issue38297] Imports at top of module is often not used

2019-09-30 Thread Brett Cannon
Brett Cannon added the comment: So it's a bit misleading to use the stdlib as a guideline because there are reasons we do this in certain spots. E.g. the os module purposefully does function-level imports to make startup cheaper. importlib does this to minimize how many modules need to be fr

[issue38297] Imports at top of module is often not used

2019-09-28 Thread Dominic Littlewood
Dominic Littlewood <11dlittlew...@gmail.com> added the comment: I've slightly adjusted the script to check for module-level imports not at the top of the file. If we permit things like this: if condition: import module else: do_something_sensible() as long as they are at the top of th

[issue38297] Imports at top of module is often not used

2019-09-27 Thread Eric V. Smith
Eric V. Smith added the comment: I think PEP 8 should say "Module-level imports are always put at the top of the file, ...". -- nosy: +eric.smith ___ Python tracker ___ _

[issue38297] Imports at top of module is often not used

2019-09-27 Thread Dominic Littlewood
New submission from Dominic Littlewood <11dlittlew...@gmail.com>: In PEP 8, it is stated that: "Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants." Note the word "always". This advice makes sense because it cut