mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-26 19:01:08 +03:00
Fixed bug that resulted in false positive error when second argument to NewType
call contained a Type
object.
This commit is contained in:
parent
ec478e68de
commit
029eb2c869
@ -9176,7 +9176,7 @@ export function createTypeEvaluator(
|
||||
}
|
||||
|
||||
if (argList.length >= 2) {
|
||||
const baseClass = getTypeForArgumentExpectingType(argList[1]);
|
||||
const baseClass = transformTypeObjectToClass(getTypeForArgumentExpectingType(argList[1]));
|
||||
|
||||
if (isClass(baseClass)) {
|
||||
if (ClassType.isProtocolClass(baseClass)) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This sample tests the type handler's handling of the
|
||||
# built-in NewType function.
|
||||
|
||||
from typing import NewType
|
||||
from typing import NewType, Type, TypeVar
|
||||
|
||||
MyString = NewType("MyString", str)
|
||||
|
||||
@ -22,3 +22,13 @@ must_take_my_string(MyString("hello"))
|
||||
# This should generate an error because 'hello'
|
||||
# isn't a valid MyString.
|
||||
must_take_my_string("hello")
|
||||
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
|
||||
def func1(x: Type[_T]) -> Type[_T]:
|
||||
return x
|
||||
|
||||
|
||||
MyString2 = NewType("MyString2", func1(str))
|
||||
|
Loading…
Reference in New Issue
Block a user