From 2ff7c0de571d434a9a1f82fa183d32fa32999b40 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 22 Jul 2023 23:18:19 +0100 Subject: [PATCH] [release 1.5] stubtest: Fix `__mypy-replace` false positives (#15689) (#15751) --- mypy/stubtest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index f06faa962b07..906a8c923b37 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -496,7 +496,11 @@ def verify_typeinfo( ) # Check everything already defined on the stub class itself (i.e. not inherited) - to_check = set(stub.names) + # + # Filter out non-identifier names, as these are (hopefully always?) whacky/fictional things + # (like __mypy-replace or __mypy-post_init, etc.) that don't exist at runtime, + # and exist purely for internal mypy reasons + to_check = {name for name in stub.names if name.isidentifier()} # Check all public things on the runtime class to_check.update( m for m in vars(runtime) if not is_probably_private(m) and m not in IGNORABLE_CLASS_DUNDERS