Skip to content

Incompatible override too strict on empty tuple #2518

@grievejia

Description

@grievejia

Describe the Bug

Minimal repro:

class TestBase:
    __requires__ = ()

class FeatureTest(TestBase):
    __requires__ = ("feature_x",)  # FP: tuple literal type mismatch

Only mypy complains here. Pyright and ty both choose to be more permissive, which is understandable given that an empty tuple base attr almost always means to hold a tuple of something in derived classes (similar to how an attr initialized with None almost always mean to have type Optional[Something] instead of NoneType.

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQAq8ALgEK0yIA669-9APqCATjACOAVwhi4w%2BgF56ACgCUvDemq0GAMRioWksczgtlp9p1U8%2BA4WKkz48pcu7gDRsYPweANKr8AMT0ugAKiPRGxLD0UBAsMCKoUNGkxDD0ALYQcNmGlAAWIP4gkizQcCTkiCChAKqVCSyk9GCSWpW46HCamDBg7bgiBSyC6JLZ2MnK%2BFEQ6CxBALQAfPRmIrYC9GLefGAeAHJTM9v0wPgAvh68pSBkYmBQpIQsuNlQFKHhpM%2BvTYYHAEeiUHqQADmxkMEB6hF4oQAyjAskUWCxiHBEAB6HFPQavQgjSE4mDoHGYXCUOA48HoKEw7oU4YieioABuqGgqGwcXpjJSzPouGIzOqvDILCKPRWHOScDhfCUHgAzIQAIwAJju6BA1zKqEolXlumgMAoaCweCIZH1QA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

typecheckingusabilityUsability & readiness issues identified with running Pyrefly on top OSS projects

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions