Commit Graph

7548 Commits

Author SHA1 Message Date
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
Eric Traut
19183640d8 Fixed a bug in bindFunctionToClassOrObject function that resulted in incorrect results when binding a class object to a method in its metaclass. Also renamed the treatConstructorAsClassMethod parameter for clarity. 2024-04-13 18:27:30 -07:00
Eric Traut
975c846895
Fixed bug that results in incorrect type evaluation when solving a ParamSpec type when there are multiple constraints provided. (#7692) 2024-04-13 17:34:02 -07:00
Eric Traut
567d025f48
Added missing check for the errant use of class-scoped type variables in a type annotation for the "self" parameter within an "__init__" method. The typing spec now clarifies that this is illegal and should generate an error. This addresses #7683. (#7691) 2024-04-13 09:49:17 -07:00
Eric Traut
d7dce3b6a8
Modified handling of annotated self parameter in __init__ method when evaluating constructor call so pyright conforms to the latest typing spec. This addresses #7682. (#7690) 2024-04-13 09:31:11 -07:00
Eric Traut
dfe428190c
Fixed bug that results in a spurious reportAbstractUsage error when an abstract class is captured through a type[T]. This addresses #7680. (#7681) 2024-04-12 23:10:30 -07:00
Eric Traut
92f2284d24 Changed behavior when evaluating the upper bound expression, value constraints expression, or default expression for a PEP-695 type parameter. At runtime, these are always evaluated in a deferred manner even if they are not quoted. Pyright now follows the runtime behavior. This addresses #7678. 2024-04-12 14:08:05 -07:00
Eric Traut
f2e277aa5c
Fixed recent regression that results in a false positive error when applying a @property decorator to a method that has already had a decorator applied to it. This addresses #7667. (#7671) 2024-04-11 20:44:46 -07:00
Eric Traut
dd09712579
Extended type narrowing logic for in and not in operators that target TypedDicts to also support constrained TypeVars that use TypedDicts as value constraints. This addresses #7666. (#7670) 2024-04-11 17:53:24 -07:00