Eric Traut
42962e796f
Split out type evaluator tests into more files and rebalanced them to take advantage of machines with more cores. On my new MacBook Pro, this drops the time to run tests from 45s to 23s.
2024-04-29 22:23:50 -07:00
Eric Traut
01c512ee7e
Fixed bug that resulted in incorrect evaluation of an identifier used in a method parameter type annotation if it shadows a forward reference in a class scope when the method is using PEP 695 type parameters. This addresses #7800 .
2024-04-29 22:06:54 -07:00
Eric Traut
0af66f4468
Fixed a bug that results in incorrect type evaluation when a global (module-scoped) variable is captured within an inner scope and the variable is not modified anywhere below the inner scope. It's possible in this case for the variable to be modified by code outside of the module. This addresses #7780 . ( #7803 )
2024-04-29 16:16:32 -07:00
Eric Traut
fcf5b372be
Changed the tokenizer so it is bug-for-bug compatible with the CPython tokenizer in versions 3.10 and newer in the case where a backslash (continuation character) is located by itself on a line. This addresses #7799 .
2024-04-29 16:00:54 -07:00
Eric Traut
1aed0e3261
Fixed a false negative that occurs when reassigning a Final
variable within a class body. This addresses #7797 . ( #7801 )
2024-04-29 15:36:45 -07:00
Eric Traut
4c1eb615af
Fixed a bug that results in a false positive error when Callable()
is used as a class pattern and the subject type is Any
or Unknown
. This addresses #7794 . ( #7796 )
2024-04-28 18:44:26 -07:00
Eric Traut
556608dffd
Fixed a bug that leads to an infinite loop when performing protocol matching under certain circumstances that involve recursive protocol definitions. This addresses #7786 .
2024-04-27 19:33:17 -07:00
Eric Traut
47c53f9b5b
Fixed a bug that results in a false positive error when using __extra_items__
(PEP 728) with a TypedDict
imported from typing_extensions
. This addresses #7784 .
2024-04-27 15:52:43 -07:00
Eric Traut
2743ba5cbf
Fixed a bug that led to poor performance (effectively a hang) if an unannotated function is called through many (greater than 8) call expressions within a loop using different literal-value arguments each time. This addresses #7791 . ( #7792 )
2024-04-27 15:45:29 -07:00
Eric Traut
0a8e1b7af6
Fixed documentation and json schema for reportMissingTypeStubs
default. This addresses #7789 .
2024-04-26 21:40:57 -07:00
Eric Traut
6950622347
Issue7779 ( #7781 )
...
* Changed `TypeIs` to use the same logic as `isinstance` type narrowing logic for consistency. This addresses #7767 , #7760 , and #7647 .
* Fixed bug that results in a false positive error when a `yield` statement is used within a lambda following a function. This addresses #7779 .
2024-04-26 09:51:58 -07:00
Eric Traut
96d0145763
Changed TypeIs
to use the same logic as isinstance
type narrowing logic for consistency. This addresses #7767 , #7760 , and #7647 . ( #7777 )
2024-04-25 22:19:04 -07:00
Eric Traut
c2203b9aa7
Fixed bug that resulted in incorrect bidirectional type inference when calling a constructor for a generic class that defines no __new__
or __init__
method. This addresses #7764 . ( #7776 )
2024-04-25 21:10:10 -07:00
Eric Traut
c640765de5
Changed logic that synthesizes the constructor methods for a NamedTuple subclass (using the class syntax) so the __new__
method contains parameters based on field names and the __init__
method contains a general *args: Any, **kwargs: Any
parameter signature. Previously, this was swapped, but the new way is more faithful to the runtime. This addresses #7769 .
2024-04-25 20:30:30 -07:00
Eric Traut
7194375bff
Fixed bug caused by incorrect synthesis of item
and keys
attributes for named tuple classes. This addresses #7768 . ( #7775 )
2024-04-25 19:50:12 -07:00
Eric Traut
547a15021b
Fixed a bug that results in a false negative when using bidirectional type inference to evaluate the type of a lambda expression if the expected type is a union of two or more callables. This addresses #7772 . ( #7773 )
2024-04-25 19:37:15 -07:00
Erik De Bonte
4bc8428d75
Follow-up pull from Pylance ( #7766 )
2024-04-25 07:23:15 -07:00
PylanceBot
ffcd90bb91
Pull Pylance with Pyright 1.1.360 ( #7761 )
...
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Co-authored-by: Rich Chiodo <rchiodo@microsoft.com>
Co-authored-by: Stella Huang <stellahuang@microsoft.com>
Co-authored-by: Kacie Kang <jikang@microsoft.com>
2024-04-24 17:58:06 -07:00
Eric Traut
f4afe405cd
Published 1.1.360
2024-04-23 22:00:23 -07:00
Eric Traut
e5c0b59c77
Fixed bug that leads to incorrect metatype for a class object that is created by calling the metaclass with a two-argument form.
2024-04-23 21:58:46 -07:00
Eric Traut
d33a1051dd
Fixed bug that leads to false negative when binding an object to an overloaded method where all of the overloads have incompatible self
parameter types. This addresses #7742 . ( #7755 )
2024-04-23 21:47:13 -07:00
Eric Traut
7c8e8ba8e0
Updated typeshed stubs to the latest version.
2024-04-23 21:26:05 -07:00
Eric Traut
400bb92da0
Redesigned the handling of PEP 695-style type parameter scoping to better match the CPython runtime implementation. This addresses #7716 and #7737 . ( #7754 )
2024-04-23 21:05:07 -07:00
Eric Traut
3875288287
Fixed a bug that results in a false positive error when bidirectional type inference is used for a dictionary comprehension when the expected type is a union. This addresses #7741 . ( #7751 )
2024-04-23 00:01:47 -07:00
Eric Traut
cd483dcb90
Fixed bug in protocol matching that results in a false positive when the subject object is a dataclass that contains a callable. It should be considered an instance member in this case, so it should not be bound to the class. This addresses #7735 . ( #7749 )
2024-04-22 20:47:48 -07:00
Eric Traut
d1461cee9f
Changed behavior to no longer exempt unguarded access to not-required TypedDict member within a try
or with
block. Previously, such errors were exempt, but this is inconsistent with other type checks in pyright which eschew the practice of using exception handling for normal code flow. This addresses #7714 . ( #7748 )
2024-04-22 18:39:45 -07:00
Eric Traut
73d894c1be
Fixed recent regression that incorrectly narrowed the type of kwargs
when used in a type guard of the form if "a" in kwargs
. This addresses #7731 . ( #7747 )
2024-04-22 18:19:10 -07:00
Eric Traut
419a8f41c1
Fixed recent regression that affected unannotated __call__
methods in a metaclass. This change aligns pyright's behavior to the typing spec. It addresses #7717 . ( #7746 )
2024-04-22 17:50:11 -07:00
Eric Traut
9ca7cbd48c
Updated documentation to show that PEP 742 is no longer in draft form.
2024-04-22 17:35:27 -07:00
Max Muoto
591b0d0a5a
Update typing docs with Pycharm usage ( #7744 )
2024-04-22 14:33:23 -07:00
Eric Traut
f22576f0f8
Moved check for invalid use of class-scoped TypeVar within a self
annotation in __init__
. It was previously reported under reportGeneralTypeIssues
, but it's now moved to reportInvalidTypeVarUse
. This was done to help typeshed maintainers migrate away from this pattern. https://github.com/python/typeshed/pull/11780#issuecomment-2070101577
2024-04-22 09:51:32 -07:00
InSync
687fadef75
Fix a few typos in docs/configuration.md
( #7739 )
...
* Fix a typo
* Add missing "default" clause
2024-04-22 09:09:37 -07:00
Eric Traut
c7168d7068
Added support for @deprecation messages for decorators that wrap a function in a callable object. The deprecated message is now propagated through the ParamSpec and the __call__
method. This addresses #7732 .
2024-04-21 21:22:07 -07:00
Heejae Chang
0127fd67ad
log type evals perf when option is on ( #7729 )
2024-04-19 18:11:58 -07:00
Heejae Chang
a8399d3933
Don't use Uri.Empty for default workspace. ( #7654 )
...
* Don't use Uri.Empty for default workspace.
* addressed PR feedback
2024-04-17 16:31:52 -07:00
Erik De Bonte
69ded75d4b
Loc update from Pylance ( #7720 )
2024-04-17 13:00:35 -07:00
Erik De Bonte
fc1b547130
Push pylance changes to pyright ( #7719 )
...
Co-authored-by: Bill Schnurr <bschnurr@microsoft.com>
Co-authored-by: HeeJae Chang <hechang@microsoft.com>
Co-authored-by: Erik De Bonte <erikd@microsoft.com>
Co-authored-by: Rich Chiodo <rchiodo@microsoft.com>
Co-authored-by: Stella Huang <stellahuang@microsoft.com>
Co-authored-by: Kacie Kang <jikang@microsoft.com>
2024-04-17 11:46:31 -07:00
Eric Traut
cc3467fda4
Published 1.1.359
2024-04-16 17:15:25 -07:00
Eric Traut
8912c884ce
Fixed bug that results in false positive error under certain circumstances that involve unions of TypeVars in an invariant context. This addresses #6957 . ( #7709 )
2024-04-15 23:09:21 -07:00
Eric Traut
8a7aed5983
Added a check for the case where a frozen dataclass overrides a field from its parent class but doesn't provide a default value (where its parent does). This can result in a type violation if the parent's default value is not compatible with the child's (covariant) field type. This addresses #7702 . ( #7704 )
2024-04-14 11:39:26 -07:00
Eric Traut
b1c436842c
Changed behavior of conversion from class constructor to callable to conform to honor return type of the __new__
method. This addresses #7687 . ( #7701 )
2024-04-13 23:11:53 -07:00
Eric Traut
71a3b60960
Changed behavior of conversion from class constructor to callable to conform to honor the annotated type of self
in the __init__
method. This addresses #7688 . ( #7699 )
2024-04-13 22:06:32 -07:00
Eric Traut
43fe9a7e2c
Changed behavior of conversion from class constructor to callable to conform with the typing spec in the case where the __new__
method of the class returns a value that indicates the __init__
method should be ignored. This addresses #7686 . ( #7698 )
2024-04-13 21:41:56 -07:00
Eric Traut
74880b87d3
Fixed broken build. I forgot to check in a test change.
2024-04-13 21:18:03 -07:00
Eric Traut
653e1609e7
Modified behavior in constructor call code that previously applied some (now non-compliant) heuristics to reconcile a metaclass __call__
method with a __new__
method. The new behavior is now compliant with the typing spec.
2024-04-13 21:07:40 -07:00
Eric Traut
9d87fe1079
Changed the behavior when invoking constructor for type[T]
where T
is a TypeVar with no explicit upper bound (and therefore has an implicit upper bound of object
). According to the newly-clarified typing spec, this should enforce the constructor signature of object
. ( #7697 )
2024-04-13 21:05:39 -07:00
Eric Traut
7f46092aef
Fixed a bug that leads to a false negative when an unparenthesized assignment expression is used in a dictionary key within a dictionary expression or comprehension. This addresses #7694 . ( #7696 )
2024-04-13 20:40:30 -07:00
Eric Traut
2e537e9a0f
Updated logic for converting a class constructor to a callable to conform to the newly-updated typing spec. This addresses #7684 and #7685 . ( #7693 )
2024-04-13 20:16:47 -07:00
Eric Traut
00d8f81a1c
Fixed a bug that results in incorrect type evaluation when assigning a function with a NoReturn
return type to a Callable[..., T]
.
2024-04-13 18:39:18 -07:00
Eric Traut
5c480848ce
Refactored the logic related to conversion of a class constructor to a callable in prep for further bug fixes. No functional change.
2024-04-13 18:33:33 -07:00