Commit Graph

6922 Commits

Author SHA1 Message Date
Eric Traut
9c8a0f1a4a Improved error message for set invariance type violations. This comes from mypy issue https://github.com/python/mypy/issues/16631. 2023-12-07 10:52:16 -08:00
Rich Chiodo
a5b352d929
Change all file paths to use a new URI class. (#6519)
* Preliminary idea

* First commit

* Refactor all uri based path functions to uriUtils

* Most of real code building

* More tests working

* More progress on the tests

* Rest of typecheck errors

* Move URIs even further to prevent accidental issues

* More tests

* Relative path fixes

* More test fixes and changes to 'startsWith'

* Uri tests all passing

* remove uri tests from path utils tests

* Fix relative paths for partial stub remapping

* Make isEmpty look empty and fix empty check for resolved paths

* Fix module name retrieval issue

* Use map instead of set for URI list

* Another path is empty fix.

* Fix importresolver finding source files for stubs

* Fixup actual defs to match expected format

* Relative path differences again

* Fix some comparisons

* More comparison fixes

* Config of ('.') was using current directory to find module names

* Shortcut empty URI for existence

* Add back ignoring case

* Fix regex matching

* All tests passing

* Fix build after merge

* Fix failing tests

* Fix rootDirectory and python path from interpreter

* Some perf improvements

* Don't bother reparsing in file system

* More tests and some logging output

* Extra data for analyzing slowness

* Fix build problems

* Refactor to not use vscode.URI except for initial parse

* Try without vscode uri validation

* Rework to new perf idea

* Split out class and interface

* All uri tests passing

* Fix other tests

* Cache results for faster perf

* Add memoization decorator

* combinePath remove one layer and make key gen faster

* Move caches local

* Generalize the memoization and optimize zero arg funcs

* Cache more stuff

* slight speedup for cache saving

* slight improvement by just returning the cached item

* Small optimization to skip loop if possible

* Further speedup for similar calls of combinePath

* Make it possible to switch between profiled and not

* Another small optimization

* Cache files in directory

* Small opt for isNativeModuleFileName

* Speed up getting pytyped info

* Fix command line parsing to expand ~
Slight perf improvement for exists cached by not splitting

* Split out instrumenting memoization

* Remove instrumented memoizationin

* Fix comment

* Fix build on ubuntu/mac

* Fix windows specific problems with tests
Fix auto import to work with windows file paths

* Fix command line output

* Try fixing CI path for failing test

* fix output paths in other spots

* More file output locations

* Output more data for failing test

* Put validation back and fix test

* Fix import cycles message to not show URI path

* Remove printing of config options

* More review feedback

* Missed a spot in the review feedback

* Fix build error

* Update packages/pyright-internal/src/analyzer/importResolver.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Update packages/pyright-internal/src/analyzer/analyzerFileInfo.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Update packages/pyright-internal/src/analyzer/backgroundAnalysisProgram.ts

Co-authored-by: Erik De Bonte <erikd@microsoft.com>

* Review feedback from Erik

* Revert changes to launch.json

* Fixup config options to use same roots as before

* Fix casing for cwd test on windows

* Fix spack differences

* Add back in the instrumentation until figure import resolve cache

* Fixup after merge

* Fix another equals comparison

* Merge error

* Fix after merge

* Fixup after merge

* Keep track of case sensitivity in the URIs

* Fix test failures on windows/mac

* Switch to the faster version

* Remove memoization

* Review feedback for some renames

* Review feedback

* Feedback from Erik, put back memoization for simple stuff

* fix prettier

* Fix typo and cache URI creations

* Add a comment

* Review feedback from Eric

* Fix crash in config options

* Missed a piece of feedback

---------

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
2023-12-07 09:15:39 -08:00
Eric Traut
07568b047d
Fixed bug in narrowing logic for sequence pattern magic where special cases of str, bytes, and bytearray were not handled correctly. This addresses #6670. (#6671) 2023-12-06 22:03:22 -08:00
Eric Traut
0e71f1dbf9 Fixed a bug that resulted in a crash under certain circumstances when defining a type alias using a type statement when no type parameters are defined. This addresses #6664. 2023-12-06 10:37:15 -08:00
Eric Traut
221f55591c Fixed English text for position-only error. It contained an extraneous \" at the end. 2023-12-06 09:44:42 -08:00
Eric Traut
a7b3f2e852 Fixed misspelling in comment. No functional change. 2023-12-06 01:14:40 -08:00
Eric Traut
3f8fc660f2 Published 1.1.339 2023-12-05 19:19:24 -08:00
Eric Traut
eb45e303a4 Changed the type printer logic to avoid emitting truncated Literal string and bytes values when it is asked to enforce Python syntax. This mode is used for inlay hints and the stub generator (for inferred return type comments). This addresses #6659. 2023-12-05 19:15:21 -08:00
Eric Traut
5cd59ad266
Changed behavior of two-argument form of super when it is used outside of an attribute access expression. It now employs a heuristic whereby it evaluates to the next base class of the bound type. This addresses #6660. (#6662) 2023-12-05 18:13:27 -08:00
Eric Traut
c93d9ebf88 Added test case for #6645. 2023-12-05 00:21:29 -08:00
Eric Traut
0345c450cc
Fixed bug that resulted in incorrect narrowed type evaluation in certain circumstances involving certain code flow graph structures. This addresses #6645. (#6653) 2023-12-04 23:57:47 -08:00
Eric Traut
590617fa20
Fixed bug that led to improper type narrowing for class patterns when Callable is used. This addresses #6648. (#6650) 2023-12-04 18:42:57 -08:00
Eric Traut
3a50763c7e Added support for doc strings when using the PEP 695 type statement. This addresses #6647. 2023-12-04 17:01:20 -08:00
Eric Traut
b15e6b9cd5
Fixed a bug in the code flow engine that resulted in a false negative for a variable whose type is narrowed within an inner loop. This addresses #6417. (#6642) 2023-12-03 18:07:36 -08:00
Eric Traut
53e7f116c6
Fixed a bug that resulted in incorrect type evaluation in certain cases involving generic protocols and bound TypeVars. This addresses #6579. (#6641) 2023-12-03 11:17:08 -08:00
Eric Traut
96afb820f4 Fixed style issue. 2023-12-02 15:35:45 -08:00
Eric Traut
48c7179d2e Added a few optimizations that help improve perf somewhat when large unions are involved. This is related to #6594. 2023-12-02 15:22:30 -08:00
Eric Traut
935e21cfc6 Fixed regression that resulted in a false negative for the reportUnknownMemberType check when the expression is a call argument and the member is a function with a partially-unknown signature. This addresses #6634. 2023-12-02 14:00:47 -08:00
Eric Traut
bab608f211
Enhanced support for TypeVarTuple capture of a callable to support literal arguments. This addresses #6635. (#6638) 2023-12-02 13:46:31 -08:00
Eric Traut
71d43a8c4e Small improvement to test case. 2023-12-02 13:40:29 -08:00
Eric Traut
c322aaa20d
Fixed bug that resulted in incorrect type evaluation when del statement is applied to a class member implemented with a descriptor. This addresses #6636. (#6637) 2023-12-02 12:07:55 -08:00
Eric Traut
4fdbf2219b Fixed bug that resulted in a crash within the function return type checking logic. This addresses #6632. 2023-12-02 01:49:54 -08:00
Eric Traut
559f9194ac
Fixed bug that led to incorrect type evaluation with unary operator when used with a type alias defined with forward references. This addresses #6629. (#6631) 2023-12-02 01:28:32 -08:00
Eric Traut
f605c8fb24
Added a new typeCheckingMode called "standard". It's a subset of "strict" but a superset of "basic". It is the new default mode, and it should cover all of the required checks for conformance with the Python typing standard. This addresses #66607. (#6627) 2023-12-01 23:44:12 -08:00
José Vicente Barrachina
f82a594102
Update package.nls.es.json (#6625)
Fixed a couple of typos in Spanish localization.
2023-12-01 23:06:58 -08:00
Eric Traut
f79e18033e
Added support for *args: *Ts parameter that captures a callable with an indeterminate number of positional parameters because some of them have default arguments. This addresses #6613. (#6623) 2023-12-01 22:01:09 -08:00
Eric Traut
c43f6f6a33
Fixed bug that results in incorrect type evaluation when a raise statement is used within a context manager that swallows exceptions. This addresses #6620. (#6621) 2023-12-01 18:42:07 -08:00
Eric Traut
703215a42a
Moved checks for Required/NotRequired and ReadOnly overrides from reportGeneralTypeIssue to reportIncompatibleVariableOverride for consistency. Added checks for Required/NotRequired and Readonly incompatibilities in the multiple inheritance case. (#6618)
This addresses #6589.
2023-12-01 17:42:53 -08:00
Eric Traut
23942f31e9 Fixed bug that affected the case where a TypedDict class derived from two incompatible classes using multiple inheritance. The error was reported in the wrong location. 2023-12-01 11:32:22 -08:00
Eric Traut
a286882003 Added an error check for a PEP 695 type statement within a function body. Type alias definitions are not allowed within this scope. This addresses #6610. 2023-11-30 20:08:28 -08:00
Eric Traut
ed8062cf7b Added support for accessing members of a TypeAliasType object. This addresses #6576. 2023-11-30 19:42:06 -08:00
Eric Traut
3131cf278b Removed some dead code. 2023-11-30 18:46:51 -08:00
Eric Traut
3718a549d1
Changed behavior of reportUnknownMemberType (and other checks in the reportUnknown... family) to not report a partially-unknown type if it refers to an unspecialized class. This addresses #6582. (#6608) 2023-11-30 16:33:51 -08:00
Eric Traut
4aacf010a1
Fixed recent regression that results in false positive error where type or type[Any] is not considered type compatible with Callable. This addresses #6600. (#6606) 2023-11-30 15:38:32 -08:00
Eric Traut
249d4c504b
Fixed a bug that results in a false positive when anext is passed a value of type AsyncIterator. This addresses #6598. (#6601) 2023-11-30 12:13:30 -08:00
Eric Traut
b2b34ac9c8
Implemented check for inconsistent use of @staticmethod and @classmethod in overloads. This addresses #6592. (#6599) 2023-11-30 11:51:02 -08:00
Eric Traut
cdbf909d18
Fixed recent regression that resulted in a false negative when type or type[Any] was used as a type annotation for a field in a dataclass. This addresses #6596. (#6597) 2023-11-30 11:02:12 -08:00
Eric Traut
99224046e5 Added support in dataclass_transform for custom field specifiers that have default arguments for their init or kw_only parameters. This addresses #6573. 2023-11-30 00:16:45 -08:00
Eric Traut
69f65bcbd0 Fixed build break. 2023-11-29 20:27:21 -08:00
Eric Traut
b4d645d501 Removed the "add optional for param" quick command. It has been broken for a long time, and no one has noticed. 2023-11-29 20:23:29 -08:00
Eric Traut
cb90b31407
Fixed bug that resulted in a false positive error when overriding a TypedDict field when the overridden type was Any or vice versa. This addresses #6590. (#6593)
Fixed bug that resulted in a false negative when overriding a TypedDict field with an incompatible `Required` or `NotRequired` attribute. This addresses #6588.
2023-11-29 20:11:12 -08:00
Eric Traut
70a19594b1 Changed behavior of check for unimplemented methods in a class that explicitly derives from a protocol. If the class also explicitly derives from abc.ABC, it is exempted from this check. This is useful for mixin classes. This addresses #6586. 2023-11-29 17:39:17 -08:00
Eric Traut
182d739298 Fixed a bug that resulted in a false positive when Self was used in a value expression outside of a class body. This addresses #6587. 2023-11-29 16:57:52 -08:00
Eric Traut
90faf4a574
Fixed a bug that resulted in a false positive error under certain circumstances involving inferred variance, decorators and generic type aliases. This addresses #6574. (#6578) 2023-11-29 11:50:11 -08:00
Eric Traut
a32d0e0fb6 Published 1.1.338 2023-11-28 22:10:43 -08:00
Rich Chiodo
5148c9de9d
Include directories in the folder map for mapped partial stubs (#6560)
* Include directories in the folder map for mapped partial stubs

* Remove debug only code

* Fix formatting

* Review feedback - move logic to recordMovedEntry

* Further simplification

* Add some more comments
2023-11-28 16:32:15 -08:00
Eric Traut
d3398850c4 Fixed documentation for class and instance variable overrides. 2023-11-28 13:21:16 -08:00
Eric Traut
5471f6cc99
Fixed bug that produces a false negative when attempting to assign a method to a Callable type where the first parameter of the method is typed as Self, but the callback requires the class itself. This addresses #6568. (#6569) 2023-11-28 12:52:06 -08:00
Eric Traut
5b3523ff53
Added support for parameter type inference for lambdas whose parameters include default arguments. This is analogous to the logic used for unannotated function parameters with default arguments. This addresses #6558. (#6563) 2023-11-27 17:51:31 -08:00
Eric Traut
f7e247986f
Fixed bug that led to a false negative when Never is used as an explicit type argument for a generic class or type alias if the corresponding type parameter is a constrained TypeVar. This addresses #6557. (#6562) 2023-11-27 17:26:09 -08:00