-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support linting entrypoints that don't end in .py
#5441
Comments
…clude" directives end in ".py" or ".pyi". This addresses #5441.
Thanks, I think you've made a compelling argument for removing this limitation. I don't think it was even added intentionally — at least not for the CLI. It was added in a code path that is used for the |
Nice. Thanks a lot for getting onto that so quickly @erictraut ! |
This is included in pyright 1.1.317, which I just published. |
There's been a number of issues (e.g. #3398, #3163) with minor use cases for why the current "no
.pyi?
extension = not a Python file" behaviour is frustrating.I'd like to instead focus the discussion on an established, widespread, use-case: Unix shebangs . Python's even monkey-patched support into the launcher so they can be used on Windows. There's lots of discourse on whether executables with shebangs and file extensions make sense, with lots of standard tools seemingly on the no side. For example, this returns 218 results on my machine:
What adds to the confusion is my editor happily lints these with Pyright (presumably because it's determined the file type, then passed the raw text to the running language server). If it can be done in the editor, it would be nice if that was consistent with what I can do via the cli.
Personally, I feel decisions like this shouldn't be made authoritatively by a linter. Let the user decide what they want to pass to the linter, and they can suffer the consequences of "rubbish in equals rubbish out". If there's a way it could be valid Python usage, please let us pass it in.
note: the limiting to
.pyi?
files makes perfect sense for things that are imported, that's a detail of how Python works, I'm just talking about the entrypoints here for a command likepyright --verbose my_shebang_python_file_with_no_extension
Possible solutions
There's a number:
Personal preference would be for either of the last two. Hopefully something there can both align with the design goals of the project, and support linting of well-established Python usage practices.
Tip for those needing to get around this for now
npm install pyright
as normal.pyi?
extension = not a Python file" regex from here:The text was updated successfully, but these errors were encountered: