mirror of https://github.com/astral-sh/ruff
wiring up NewType calls
This commit is contained in:
parent
24f6d2dc13
commit
790cce4628
|
|
@ -4257,6 +4257,20 @@ impl<'db> Type<'db> {
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some(KnownClass::NewType) => Binding::single(
|
||||||
|
self,
|
||||||
|
Signature::new(
|
||||||
|
Parameters::new([
|
||||||
|
Parameter::positional_or_keyword(Name::new_static("name"))
|
||||||
|
.with_annotated_type(Type::LiteralString),
|
||||||
|
Parameter::positional_or_keyword(Name::new_static("tp")),
|
||||||
|
]),
|
||||||
|
// TODO: What should this return type be?
|
||||||
|
Some(KnownClass::NewType.to_instance(db)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
|
||||||
Some(KnownClass::Object) => {
|
Some(KnownClass::Object) => {
|
||||||
// ```py
|
// ```py
|
||||||
// class object:
|
// class object:
|
||||||
|
|
|
||||||
|
|
@ -1056,6 +1056,22 @@ impl<'db> Bindings<'db> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some(KnownClass::NewType) => match overload.parameter_types() {
|
||||||
|
[Some(Type::StringLiteral(name)), Some(supertype)] => {
|
||||||
|
let params = DataclassParams::default();
|
||||||
|
overload.set_return_type(Type::from(ClassLiteral::new(
|
||||||
|
db,
|
||||||
|
ast::name::Name::new(name.value(db)),
|
||||||
|
what_goes_here,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6231,6 +6231,7 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
| KnownClass::TypeVar
|
| KnownClass::TypeVar
|
||||||
| KnownClass::TypeAliasType
|
| KnownClass::TypeAliasType
|
||||||
| KnownClass::Deprecated
|
| KnownClass::Deprecated
|
||||||
|
| KnownClass::NewType
|
||||||
)
|
)
|
||||||
) || (
|
) || (
|
||||||
// Constructor calls to `tuple` and subclasses of `tuple` are handled in `Type::Bindings`,
|
// Constructor calls to `tuple` and subclasses of `tuple` are handled in `Type::Bindings`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue