Skip to content

False negative when pattern matching with a non-class #2592

@lihu-zhong

Description

@lihu-zhong

Summary

This may be a duplicate of #887 but I didn't see this specific case mentioned, so I'm throwing it out here. Feel free to close if another issue isn't necessary.

Observed behavior

The following code passes ty but throws a TypeError at runtime:

foo = "foo"

match "bar":
  case foo():
    ...

Expected behavior

ty should raise an error when a non-type is used in a class pattern when matching. Both mypy and pyright catch this.

Version

0.0.10

Metadata

Metadata

Labels

runtime semanticsAccurate modeling of how Python's semantics work at runtime

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions