ruff
4abc5fe2 - [ty] Add support for dynamic `type()` classes (#22291)

Commit
14 days ago
[ty] Add support for dynamic `type()` classes (#22291) ## Summary This PR adds support for dynamic classes created via `type()`. The core of the change is that `ClassLiteral` is now an enum: ```rust pub enum ClassLiteral<'db> { /// A class defined via a `class` statement. Stmt(StmtClassLiteral<'db>), /// A class created via the functional form `type(name, bases, dict)`. Functional(FunctionalClassLiteral<'db>), } ``` And, in turn, various methods on `ClassLiteral` like `body_scope` now return `Option` or similar (and callers must adjust to that change in signature). Over time, we can expand the enum to include functional namedtuples, etc. (I already have this working in a separate branch, and I believe it slots in well.) (I'd love help with the names -- I think `StmtClassLiteral` is kind of lame. Maybe `DeclarativeClassLiteral`?) Closes https://github.com/astral-sh/ty/issues/740. --------- Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Author
Parents
Loading