Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Issue warning for enum with no members in stub#18068

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hauntsaninja merged 5 commits intopython:masterfromhauntsaninja:enum-followup
Oct 30, 2024

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninjahauntsaninja commentedOct 29, 2024
edited
Loading

Follow up to#17207

@github-actions

This comment has been minimized.

ifbase.is_enumandbase.fullnamenotinENUM_BASES:
self.check_final_enum(defn,base)

ifself.is_stubandnotself.is_typeshed_stubandself.tree.fullname!="enum":

Choose a reason for hiding this comment

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

Why do we need to exclude typeshed? Didn't we already fix this in typeshed?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

This was before I added the check against enum.pyi specifically. Looks like I'd also need to silence_typeshed because it has some StrEnum stuff

@github-actions
Copy link
Contributor

Diff frommypy_primer, showing the effect of this PR on open source code:

python-htmlgen (https://github.com/srittau/python-htmlgen)+ htmlgen/form.pyi:8: error: Detected enum "htmlgen.form.Autocomplete" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ htmlgen/form.pyi:8: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ htmlgen/video.pyi:6: error: Detected enum "htmlgen.video.Preload" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ htmlgen/video.pyi:6: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-membersTanjun (https://github.com/FasterSpeeding/Tanjun)+ tanjun/_internal/vendor/inspect.pyi:196: error: Detected enum "tanjun._internal.vendor.inspect._ParameterKind" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ tanjun/_internal/vendor/inspect.pyi:196: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-memberspandas (https://github.com/pandas-dev/pandas)+ pandas/_libs/tslibs/dtypes.pyi:31: error: Detected enum "pandas._libs.tslibs.dtypes.FreqGroup" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas/_libs/tslibs/dtypes.pyi:31: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ pandas/_libs/tslibs/dtypes.pyi:48: error: Detected enum "pandas._libs.tslibs.dtypes.Resolution" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas/_libs/tslibs/dtypes.pyi:48: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ pandas/_libs/tslibs/dtypes.pyi:70: error: Detected enum "pandas._libs.tslibs.dtypes.NpyDatetimeUnit" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas/_libs/tslibs/dtypes.pyi:70: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-membersdjango-stubs (https://github.com/typeddjango/django-stubs)+ django-stubs/db/models/constants.pyi:5: error: Detected enum "django.db.models.constants.OnConflict" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/db/models/constants.pyi:5: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/contrib/gis/gdal/srs.pyi:7: error: Detected enum "django.contrib.gis.gdal.srs.AxisOrder" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/contrib/gis/gdal/srs.pyi:7: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/template/base.pyi:28: error: Detected enum "django.template.base.TokenType" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/template/base.pyi:28: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/db/models/enums.pyi:44: error: Detected enum "django.db.models.enums.Choices" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/db/models/enums.pyi:44: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/db/models/enums.pyi:63: error: Detected enum "django.db.models.enums.IntegerChoices" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/db/models/enums.pyi:63: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/db/models/enums.pyi:79: error: Detected enum "django.db.models.enums.TextChoices" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/db/models/enums.pyi:79: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/db/models/constraints.pyi:12: error: Detected enum "django.db.models.constraints.Deferrable" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/db/models/constraints.pyi:12: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ django-stubs/contrib/admin/options.pyi:47: error: Detected enum "django.contrib.admin.options.ShowFacets" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ django-stubs/contrib/admin/options.pyi:47: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-memberspandas-stubs (https://github.com/pandas-dev/pandas-stubs)+ pandas-stubs/core/interchange/dataframe_protocol.pyi:16: error: Detected enum "pandas.core.interchange.dataframe_protocol.DlpackDeviceType" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas-stubs/core/interchange/dataframe_protocol.pyi:16: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ pandas-stubs/core/interchange/dataframe_protocol.pyi:26: error: Detected enum "pandas.core.interchange.dataframe_protocol.DtypeKind" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas-stubs/core/interchange/dataframe_protocol.pyi:26: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ pandas-stubs/core/interchange/dataframe_protocol.pyi:35: error: Detected enum "pandas.core.interchange.dataframe_protocol.ColumnNullType" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas-stubs/core/interchange/dataframe_protocol.pyi:35: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members+ pandas-stubs/_libs/tslibs/dtypes.pyi:31: error: Detected enum "pandas._libs.tslibs.dtypes.Resolution" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type`  [misc]+ pandas-stubs/_libs/tslibs/dtypes.pyi:31: note: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members

# `__members__` will always be overwritten by `Enum` and is considered
# read-only so we disallow assigning a value to it
self.fail(message_registry.ENUM_MEMBERS_ATTR_WILL_BE_OVERRIDEN,sym.node)
ifdefn.info.fullnamenotinENUM_BASESand"__members__"indefn.info.names:

Choose a reason for hiding this comment

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

This is just an optimization because previously we were iterating over the whole dict unnecessarily, right?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

Yup

@hauntsaninjahauntsaninja merged commit58f7628 intopython:masterOct 30, 2024
19 checks passed
@hauntsaninjahauntsaninja deleted the enum-followup branchOctober 30, 2024 00:21
hauntsaninja added a commit to hauntsaninja/pandas-stubs that referenced this pull requestOct 30, 2024
hauntsaninja added a commit to hauntsaninja/django-stubs that referenced this pull requestOct 30, 2024
sobolevn pushed a commit to typeddjango/django-stubs that referenced this pull requestOct 30, 2024
* Update enums to reflect typing spec changesSeehttps://typing.readthedocs.io/en/latest/spec/enums.html#defining-memberspython/typing-council#11The next version of mypy will obey the spec change:python/mypy#18068pyright already requires thisCo-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Dr-Irv pushed a commit to pandas-dev/pandas-stubs that referenced this pull requestOct 30, 2024
* Update enums to reflect typing spec changesSeehttps://typing.readthedocs.io/en/latest/spec/enums.html#defining-memberspython/typing-council#11The next version of mypy will obey the spec change:python/mypy#18068pyright already requires this* warning* .* .
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@hauntsaninja@JelleZijlstra

[8]ページ先頭

©2009-2025 Movatter.jp