Comments (8)
Currently there are a handful of _private
stdlib modules in the list. Maybe that's the real bug? :)
https://github.com/PyCQA/flake8-import-order/blob/master/flake8_import_order/stdlib_list.py#L42-L44
Except it's not documented on docs.python.org so it's not something this plugin should recognize
Originally there were no internal _ modules in the stdlib list but they seem to have got added over the many years since.
from flake8-import-order.
_csv
would be a private module that you're not intended to import directly. Instead, I expect that csv
uses it under the covers and what you get from csv
is derived from _csv
. I'd argue this is doing the right thing by flagging inappropriate usage of that module (even if it's not obvious)
from flake8-import-order.
I have to import _csv
to make annotations like def write(writer: csv_writer) -> None:
. I haven't found anything appropriate for annotations like this in usual csv
module. Anyway, this is still an issue of flake8 not to recognize _csv
correctly.
from flake8-import-order.
I haven't found anything appropriate for annotations like this in usual
csv
module.
That's disappointing and surprising. I'm not sure that means you should be using _csv
.
Anyway, this is still an issue of flake8 not to recognize
_csv
correctly.
Except it's not documented on docs.python.org so it's not something this plugin should recognize. There's nothing to stop this module from being rewritten in a memory safe language that eliminates _csv
and then we're stuck attempting to recognize something that isn't present any longer.
from flake8-import-order.
So you're saying that recognizing _csv
and other such modules like_collections
, _decimal
, _json
, _random
and so on as Third Party is correct behavior? At least they should be identified as StdlibC, for example. They're not third party modules in any sense.
I haven't found anything appropriate for annotations like this in usual csv module.
That's disappointing and surprising. I'm not sure that means you should be using _csv.
It's a known issue of csv
module not exposing the class of csv.writer()
result. This SO answer suggests to use _csv._writer
: https://stackoverflow.com/a/51270295/9609843
from flake8-import-order.
So you're saying that recognizing
_csv
and other such modules like_collections
,_decimal
,_json
,_random
and so on as Third Party is correct behavior? At least they should be identified as StdlibC, for example. They're not third party modules in any sense.
I'm saying they're not documented as the standard library. They're implementation details. Referring to them is an anti-pattern.
It's a known issue of
csv
module not exposing the class ofcsv.writer()
result. This SO answer suggests to use_csv._writer
: https://stackoverflow.com/a/51270295/9609843
That's probably one of many potential solutions here. But I recognize the rest aren't on StackOverflow so they're not immediately obvious. I'd argue that https://stackoverflow.com/a/51267141 is the better solution since it seems unlikely for mypy to be able to handle other CSV readers/writers that could satisfy the API.
I'd also argue this is more of a bug for typeshed/the stdlib for not providing something here.
from flake8-import-order.
@public that's something I would agree would be a bug. I know y'all aren't really working very much on this these days, but I think a compromise would be to allow people to "extend" what the canonical list of standard library modules is with a flag to Flake8. I'm happy to help out here although I can't commit to a specific timeframe of when that would get a PR or anything.
from flake8-import-order.
The same thing applies to _socket
, which is the cPython c extension of socket
.
Referring to them is an anti-pattern.
Utilizing them directly may be an anti-pattern, but referring to them is definitely not and required by various use-cases.
In my particular use-case, I must inspect the socket on the raw requests
response's _connection or fp and ensure it's class inheritance from socket
to extract the remote peer's ip. Under cpython, because of the implementation details, this will never be an instance of socket.socket
, and will almost never be an instance of socket._socketobject
, but would typically by an instance of _socket._socket
. This ultimately traces back to urllib3
, and this 5 year old thread I started there: urllib3/urllib3#1071
from flake8-import-order.
Related Issues (20)
- pycharm: add case-sensitivity for imports on seperate lines
- 'from .a import a' should be before 'from .. import b' HOT 1
- Proposal to archive this project recommending Flake8-isort instead HOT 11
- Unable to disable warnings via tox.ini HOT 3
- pycharm: case-sensitivity of module names in "from" imports
- How to configure? HOT 9
- Not detecting local imports HOT 1
- Third-party after local import should be forbidden but isn't
- Two Third Party imports in the same block throws I201 error HOT 5
- isort-compatible style HOT 1
- Apply the ordering rules to __all__ HOT 2
- Weird I202 error HOT 5
- error in flake8-import-order setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; slice indices must be integers or None or have an __index__ method HOT 1
- Support graphlib
- flake8 version 6.0.0 regression in parsing arguments (seen with flake8-import-order extension) HOT 1
- Exception when using with flake8 v6.0.0 HOT 2
- What is the recommended way to auto-format sources to match this checker ? HOT 1
- Support linitng imports under if TYPE_CHECKING: HOT 1
- `DeprecationWarning: pkg_resources is deprecated as an API` on python 3.11 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flake8-import-order.