Skip to content

We need a policy for undocumented attributes #1902

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

Closed
gvanrossum opened this issue Feb 19, 2018 · 4 comments
Closed

We need a policy for undocumented attributes #1902

gvanrossum opened this issue Feb 19, 2018 · 4 comments
Labels
project: policy Organization of the typeshed project

Comments

@gvanrossum
Copy link
Member

gvanrossum commented Feb 19, 2018

In the past week alone I've seen several issues where well-meaning contributors wanted to add undocumented attributes to typeshed:

I think we should have a standard policy on these. I know in the past we've sometimes added such attributes, with the argument that there's existing working code that uses them. But AFAIK there's no other tool that is capable of flagging the use of undocumented attributes, so I'm kind of leaning towards seeing this as a valuable service mypy (or rather, typeshed) provides, rather than a deficiency in the stubs. For example, if we were to add these attributes to the stubs, IDEs like PyCharm would start suggesting auto-completion for undocumented attributes, which I definitely think is a bad idea. If there's something that's commonly used, it should just be included in the docs first -- the process for that is clear (file an issue on bugs.python.org).

@ambv
Copy link
Contributor

ambv commented Feb 20, 2018

This issue is why I think we need more than just a type checker. Warnings against deprecations, use of dangerous APIs, invalid combinations of arguments, etc., is something that mypy could do, even though this functionality is not related to typing. My pet example is warning against instantiating coroutines without await or an assignment.

With all the above said, typeshed documents types and mypy checks types. We are generally working pretty hard to not raise false positives because they undermine trust in the tool. "Hey, mypy is saying there's no function like that but I can see it in dir(), it's documented with help() and works at runtime!"

So, my position is this:

  • we should let any and all pull requests in that provide valid type information, including for private/undocumented/deprecated functions/classes;
  • we need to have a talk around extending mypy in ways that helps with more than just checking types. mypy could be the most powerful static analysis tool for Python ever, running circles around linters. This discussion is a bit out of scope for typeshed, but...

If we decide that mypy should indeed allow for additional warnings that aren't type errors, then extending the .pyi syntax with a standard way to mark functions/classes that should not be used, would be nice. It could be as simple as @do_not_use("implementation detail, can change without warning in a future Python version") and/or @deprecated("will be removed in Python 3.8"). But I don't want to bikeshed here.

@gvanrossum
Copy link
Member Author

I talked briefly with @JukkaL about this and he agrees with you. I propose that while we ponder how mypy can be improved to warn about the use of undocumented attributes, we add a standardized comment # undocumented to those attributes (notes: no # type: -- and this can be appended to a regular # type: XXX comments.

@gvanrossum
Copy link
Member Author

So can we close this now?

Actually we should do something similar for deprecated APIs perhaps?

@srittau srittau added the project: policy Organization of the typeshed project label Oct 21, 2018
@srittau
Copy link
Collaborator

srittau commented Oct 28, 2018

# undocumented was documented (no pun intended) in #1938.

@srittau srittau closed this as completed Oct 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
project: policy Organization of the typeshed project
Projects
None yet
Development

No branches or pull requests

3 participants