-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Must object.__dir__
return a sequence of str
, or is any iterable OK?
#114552
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
Comments
This comment was marked as resolved.
This comment was marked as resolved.
I think the Python docs can sometimes be a little imprecise about what "sequence" means. E.g., the actual code that |
Indeed. Another alternative is to fix the Python docs to match the implementation. Maybe this is something we should try first? In any case, I think it's important to be precise here, for cases, where someone uses |
I can find one use of cpython/Lib/unittest/__init__.py Lines 72 to 73 in ea3cd04
It's a module-level use of |
I suggest to move this issue to python/cpython and suggest to change the docs. Returning a set from |
object.__dir__
is incorrect.object.__dir__
return a sequence of str
, or is any iterable OK?
I've transferred this issue to CPython and made some light edits to a few comments by participants in the discussion, so that the issue thread will make sense to CPython triagers reading it for the first time. |
My 2c:
|
… iterable (pythonGH-114662) (cherry picked from commit e19103a) Co-authored-by: Nikita Sobolev <[email protected]>
… iterable (pythonGH-114662) (cherry picked from commit e19103a) Co-authored-by: Nikita Sobolev <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
According to the documentation
__dir__
must return aSequence
, but e.g. typeshed's annotations currently imply that any iterable will do:https://github.com/python/typeshed/blob/26452a7c68c6ad512be00b553f7a03f869f64be9/stdlib/builtins.pyi#L125
Linked PRs
__dir__
method docs: it allows returning an iterable #114662__dir__
method docs: it allows returning an iterable (GH-114662) #115234__dir__
method docs: it allows returning an iterable (GH-114662) #115235The text was updated successfully, but these errors were encountered: