KEMBAR78
Ignore __slotnames__ by adamchainz · Pull Request #2584 · typeddjango/django-stubs · GitHub
Skip to content

Conversation

@adamchainz
Copy link
Contributor

@adamchainz adamchainz commented Mar 26, 2025

I have made things!

I noticed that we had a lot of __slotnames__ entries in our allow lists.

I found that this is added by Python's pickling/copying machinery:

https://github.com/python/cpython/blob/5abff6960b4aecb0d5c81c7482cf3faa74e1983d/Lib/copyreg.py#L112-L161

https://github.com/python/cpython/blob/77d2fd441320ca365c34e21c475d3878f3d5d833/Objects/typeobject.c#L7036-L7083

It seems like it can be safely ignored.

I wondered if this attribute could be ignored by default in stubtest, or even added to type or object in typeshed (as list[str]), but I am not sure how sensible that is. It doesn't always exist, only after a pickle.

Related issues

n/a

@adamchainz adamchainz requested a review from sobolevn March 26, 2025 13:55
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@sobolevn sobolevn merged commit 04216c2 into master Mar 29, 2025
40 checks passed
@sobolevn sobolevn deleted the ignore_slotnames branch March 29, 2025 04:14
@ngnpope
Copy link
Member

ngnpope commented May 12, 2025

I wondered if this attribute could be ignored by default in stubtest...

It looks like we could just add this exclusion here?

@sobolevn
Copy link
Member

yes, seems reasonable, ping me on PR :)

ngnpope added a commit to ngnpope/mypy that referenced this pull request May 12, 2025
This is a cached list of names of slots added by the `copyreg` module.

See typeddjango/django-stubs#2584 for a case of
these cropping up in `django-stubs`.
ngnpope added a commit to ngnpope/mypy that referenced this pull request May 12, 2025
This is a cached list of names of slots added by the `copyreg` module.

See typeddjango/django-stubs#2584 for a case of
these cropping up in `django-stubs`.
@ngnpope
Copy link
Member

ngnpope commented May 12, 2025

yes, seems reasonable, ping me on PR :)

python/mypy#19077

sobolevn pushed a commit to python/mypy that referenced this pull request May 12, 2025
This is a cached list of names of slots added by the `copyreg` module.

See typeddjango/django-stubs#2584 for a case of
these cropping up in `django-stubs`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants