Skip to content

fix new rule - ban dynamic types #3765 - #3869

Closed
asukaminato0721 wants to merge 3 commits into
pyrefly-org:mainfrom
asukaminato0721:3765
Closed

asukaminato0721 wants to merge 3 commits into
pyrefly-org:mainfrom
asukaminato0721:3765

Conversation

@asukaminato0721

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3765

Added unsupported-dynamic-base error kind, added builtin type(name, bases, dict) checking, and documented the new error kind.

Test Plan

add test

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@asukaminato0721
asukaminato0721 marked this pull request as draft June 18, 2026 15:46
@github-actions

This comment has been minimized.

@connernilsen connernilsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, thanks for working on this!

@meta-codesync

meta-codesync Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@connernilsen has imported this pull request. If you are a Meta employee, you can view this in D113475815.

@github-actions

Copy link
Copy Markdown

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

mkdocs (https://github.com/mkdocs/mkdocs)
+ ERROR mkdocs/config/config_options.py:101:28-31: Base class `type[Self@SubConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR mkdocs/plugins.py:75:28-31: Base class `type[Self@BasePlugin]` in `type()` call is not a statically known class [unsupported-dynamic-base]

steam.py (https://github.com/Gobot1234/steam.py)
+ ERROR steam/_gc/client.py:74:32-46: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]
+ ERROR steam/enums.py:120:13-122:14: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]

spark (https://github.com/apache/spark)
+ ERROR python/pyspark/pandas/typedef/typehints.py:891:43-55: Base class `type[IndexNameTypeHolder | NameTypeHolder]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR python/pyspark/pandas/typedef/typehints.py:911:43-55: Base class `type[IndexNameTypeHolder | NameTypeHolder]` in `type()` call is not a statically known class [unsupported-dynamic-base]

prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/prefect/input/run_input.py:419:1-2: Unused `# type: ignore` comment [unused-type-ignore]

scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ ERROR src/scikit_build_core/setuptools/wrapper.py:74:14-23: Base class `type[_DistributionT]` in `type()` call is not a statically known class [unsupported-dynamic-base]

bidict (https://github.com/jab/bidict)
+ ERROR bidict/_base.py:152:47-50: Base class `type[Self@BidictBase]` in `type()` call is not a statically known class [unsupported-dynamic-base]

psycopg (https://github.com/psycopg/psycopg)
+ ERROR psycopg/psycopg/types/array.py:337:52-56: Base class `type[ArrayLoader] | Any` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR psycopg/psycopg/types/json.py:120:26-30: Base class `type[Dumper]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR psycopg/psycopg/types/json.py:140:26-30: Base class `type[Loader]` in `type()` call is not a statically known class [unsupported-dynamic-base]

schemathesis (https://github.com/schemathesis/schemathesis)
+ ERROR src/schemathesis/core/deserialization.py:137:54-64: Base class `type[CSafeLoader] | type[SafeLoader]` in `type()` call is not a statically known class [unsupported-dynamic-base]

beartype (https://github.com/beartype/beartype)
+ ERROR beartype/_util/cls/utilclsmake.py:104:27-37: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]

pandera (https://github.com/pandera-dev/pandera)
+ ERROR pandera/api/dataframe/model.py:288:42-52: Base class `type[BaseConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/dataframe/model.py:340:55-58: Base class `type[Self@DataFrameModel]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/dataframe/model.py:507:32-42: Base class `type[BaseConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/pyspark/model.py:214:55-58: Base class `type[Self@DataFrameModel]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/xarray/model.py:263:32-42: Base class `type[DataArrayConfig | DataTreeConfig | DatasetConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/xarray/model.py:469:42-52: Base class `type[DataArrayConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/xarray/model.py:571:42-52: Base class `type[DatasetConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pandera/api/xarray/model.py:684:42-52: Base class `type[DataTreeConfig]` in `type()` call is not a statically known class [unsupported-dynamic-base]

pytest-autoprofile (https://gitlab.com/TTsangSC/pytest-autoprofile)
+ ERROR src/pytest_autoprofile/_doctest.py:361:38-48: Base class `type[DocTestRunner]` in `type()` call is not a statically known class [unsupported-dynamic-base]

ibis (https://github.com/ibis-project/ibis)
+ ERROR ibis/expr/operations/udf.py:155:51-60: Base class `[B: Value[Unknown]](self: Self@_UDF) -> type[B]` in `type()` call is not a statically known class [unsupported-dynamic-base]

strawberry (https://github.com/strawberry-graphql/strawberry)
+ ERROR strawberry/tools/merge_types.py:35:39-44: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]
+ ERROR strawberry/types/base.py:341:14-25: Base class `type[Any]` in `type()` call is not a statically known class [unsupported-dynamic-base]

hydpy (https://github.com/hydpy-dev/hydpy)
+ ERROR hydpy/core/modeltools.py:3251:61-74: Base class `type[Any]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR hydpy/core/testtools.py:1401:47-55: Base class `type[T_inv]` in `type()` call is not a statically known class [unsupported-dynamic-base]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ERROR ddtrace/vendor/debtcollector/moves.py:192:39-48: Base class `type[object]` in `type()` call is not a statically known class [unsupported-dynamic-base]

pandas (https://github.com/pandas-dev/pandas)
+ ERROR pandas/tseries/holiday.py:819:34-44: Base class `type[AbstractHolidayCalendar] | Unknown` in `type()` call is not a statically known class [unsupported-dynamic-base]

werkzeug (https://github.com/pallets/werkzeug)
+ ERROR src/werkzeug/test.py:819:32-48: Base class `type[Response]` in `type()` call is not a statically known class [unsupported-dynamic-base]

core (https://github.com/home-assistant/core)
+ ERROR homeassistant/helpers/deprecation.py:110:14-23: Base class `type` in `type()` call is not a statically known class [unsupported-dynamic-base]

spack (https://github.com/spack/spack)
+ ERROR lib/spack/spack/builder.py:137:17-22: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]
+ ERROR lib/spack/spack/util/lang.py:706:50-60: Base class `type[Self@ObjectWrapper]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR lib/spack/spack/util/lang.py:706:62-73: Base class `type[Any]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR lib/spack/spack/util/lang.py:708:50-61: Base class `type[Any]` in `type()` call is not a statically known class [unsupported-dynamic-base]

pydantic (https://github.com/pydantic/pydantic)
+ ERROR pydantic/v1/config.py:183:27-39: Base classes in `type()` calls must be a tuple literal of statically known classes [unsupported-dynamic-base]
+ ERROR pydantic/v1/schema.py:1094:50-55: Base class `type[SecretBytes | SecretStr]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pydantic/v1/schema.py:1101:54-59: Base class `type[str]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR pydantic/v1/schema.py:1110:54-59: Base class `type[bytes]` in `type()` call is not a statically known class [unsupported-dynamic-base]

artigraph (https://github.com/artigraph/artigraph)
+ ERROR src/arti/internal/mappings.py:111:49-52: Base class `type[Self@TypedBox]` in `type()` call is not a statically known class [unsupported-dynamic-base]
+ ERROR src/arti/types/__init__.py:341:18-21: Base class `type[Self@_ScalarClassTypeAdapter]` in `type()` call is not a statically known class [unsupported-dynamic-base]

@grievejia grievejia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in 5385bcc Jul 29, 2026
@meta-codesync meta-codesync Bot added the Merged label Jul 29, 2026
@meta-codesync

meta-codesync Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@connernilsen merged this pull request in 5385bcc.

@asukaminato0721
asukaminato0721 deleted the 3765 branch July 29, 2026 15:53
avokin2 pushed a commit to avokin2/pyrefly that referenced this pull request Aug 12, 2026
Summary:
Fixes pyrefly-org#3765

Added unsupported-dynamic-base error kind, added builtin type(name, bases, dict) checking, and documented the new error kind.

Pull Request resolved: pyrefly-org#3869

Test Plan: add test

Reviewed By: grievejia

Differential Revision: D113475815

Pulled By: connernilsen

fbshipit-source-id: e8f15cc94f39cd740be0df2b05406d869986cc8e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new rule - ban dynamic types

3 participants