-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Invalid pointless-string-statement
for docstrings for Python 3.12 type-aliases (PEP 695)
#9268
Comments
Ah. Here's this, if helpful: >>> n = ast.parse("""
... type MyTuple = tuple[str, str]
... "my docstring"
... """)
>>> n.body[0].__doc__
'TypeAlias(expr name, type_param* type_params, expr value)'
Interesting, I would have thought we just were being friendly to (someone's) common practice (somewhere), not observing a rejected PEP. |
I think the original rationale was that PEP. I think we might actually not want to do this? As this makes it clearer that the statement is indeed pointless and does not do what you think it does? |
Yeah, I find that convincing. |
Good to know that this type of docstring is actually not the way to go. Been using it for a while and all my tools picked it up fine so far. |
I'm interested to know which tools support it. VS Code doesn't seem to provide the docstring on hover the way it does for attributes. Are there other tools that do? |
I figured VS Code not showing any kind of hover information is just an "early adopter" problem. Was referring to that type of docstring for attributes in my earlier comment. |
Maybe worth asking on discuss.python.org? |
Posting this here to keep in sync |
Feedback from python.org is that the new type aliases are to be treated the same as regular assignments regarding docstrings. In this case I suppose it means also excluding it like Support in pyright / pylance was added for this type of docstring: microsoft/pyright#6647 |
Thanks, that's really helpful! |
Thank you! |
Bug description
Adding a multiline docstring to a Python 3.12 type-alias (PEP 695) causing pylint to faild with a
pointless-string-statement
.Example code:
Adding a
:
before the string also doesn't help:Configuration
No response
Command used
Pylint output
Expected behavior
Pylint should not raise a warning here
Pylint version
OS / Environment
macOS Sonoma, iTerm2
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: