Commit Graph

2524 Commits

Author SHA1 Message Date
Eric Traut
022f7211a0 Fixed case-sensitive test file names that broke CI on Linux. 2020-09-07 18:12:44 -07:00
Eric Traut
1939728985 Fixed bug that caused "TypeAlias" symbol (described in PEP 613) to be marked as unaccessed in some cases. 2020-09-07 17:59:12 -07:00
Eric Traut
6f235c11cb Added support for recursive type aliases. 2020-09-07 17:43:26 -07:00
Eric Traut
1e068c7af0 Updated README to include mention of PEP 563. 2020-09-07 15:51:53 -07:00
Eric Traut
ebe82b8b44 Added support for "higher-order" type variables. You can now pass a generic function as an argument to another generic function, and the type var solver can solve the type variables for both at the same time. 2020-09-07 12:32:59 -07:00
Eric Traut
fd954bae0d Another simplification of the TypeVarMap. 2020-09-07 12:32:02 -07:00
Eric Traut
4aa52c8059 Changed TypeVarMap to use keys that prefer the TypeVar scopeId rather than the TypeVar name. 2020-09-07 11:38:38 -07:00
Eric Traut
033b8be369 Improved TypeVar scoping code - no functional change. 2020-09-07 10:19:17 -07:00
Eric Traut
13e0422916 Fixed mis-ordered imports. 2020-09-07 09:24:51 -07:00
Eric Traut
84ccee95c2 Added diagnostics for type variables that are used improperly as defined in PEP 484: 1) conflicting type variables that are used in nested generic class declarations, and 2) type variables that are used within annotations outside of a context in which they have meaning. 2020-09-07 09:05:25 -07:00
Eric Traut
cb699f50db Fixed bug that affected dependency tracking of source files on platforms with case-insensitive file systems. In some cases, the case of paths differed, and the logic was treating these as separate files. 2020-09-06 10:13:34 -07:00
Eric Traut
ecfc3a2ad5 Improved type analysis perf by about 5% and reduced memory usage slightly by not formatting and logging diagnostic messages in cases where they are suppressed (e.g. argument type mismatches when doing overload matching). 2020-09-06 09:10:51 -07:00
Eric Traut
42688cd0ba Published 1.1.68 2020-09-06 00:18:56 -07:00
Eric Traut
3cbeb748e7 Fixed regression in handling of synthesized type variables. 2020-09-05 23:31:23 -07:00
Eric Traut
fc10d37761 Published 1.1.67 2020-09-05 20:11:20 -07:00
Eric Traut
d538318a01 Added special-case handling in type checker for callers who request the type of an expression that happens to be a name used in a call expression to designate a named parameter. This isn't really an expression, so the code wasn't handling it correctly, but callers (such as the hover provider and the new semantic token provider) were assuming that it was safe. This resulted in incorrect "X is not defined" diagnostics being logged. 2020-09-05 19:46:32 -07:00
Eric Traut
9145313747 Fixed a bug in the handling of generics that involve constrained TypeVars. The TypeVar matching logic was sometimes inappropriately specializing the type using the first constrained type. 2020-09-05 18:45:11 -07:00
Eric Traut
994d795c4c Fixed bug that caused a crash in the type checker in cases where type arguments were not provided to a few special-case built-in classes. 2020-09-05 18:14:03 -07:00
Eric Traut
cea376e59b Added new diagnostic rule "reportPropertyTypeMismatch" that verifies that the type of the input parameter to a property's setter is assignable to the return type of the getter. 2020-09-05 14:55:12 -07:00
Eric Traut
01637af00c Attempt to fix CI, which is hitting errors that I'm not seeing locally. 2020-09-04 21:22:42 -07:00
Eric Traut
5979e3423d Extended bidirectional type inference (expected types) to list comprehensions. 2020-09-04 21:12:19 -07:00
Eric Traut
a8406a7b02 Added localized strings for internal errors, which are reported as diagnostics. 2020-09-04 20:57:39 -07:00
Eric Traut
35ea405524 Fixed regression in recent check-in that caused an unexpected exception in import resolution code. 2020-09-04 20:57:07 -07:00
Eric Traut
2af28d9379 Changed import resolution logic to allow binaries (e.g. ".so" files) to satisfy local imports (within the package), not just third-party imports (within site-packages). 2020-09-04 20:05:51 -07:00
Eric Traut
3f63272dab Improved parser to detect syntax errors involving unpack operator within a comprehension. 2020-09-04 19:54:00 -07:00
Eric Traut
1eba08bbe5 Fixed "NoReturn" inference logic for async functions. This logic was previously flagging the code after a call to such a function as unreachable. 2020-09-04 18:50:49 -07:00
Eric Traut
09d6ea7ee0 Changed type inference logic to use "List", "Set", and "Dict" rather than "list", "set" and "dict" when inferring the type of a list, set or dict expression. These are aliases for the same underlying class, but the upper-case versions are more consistent with type annotations used within the code. 2020-09-04 15:38:06 -07:00
Eric Traut
9498da0a69 Fixed a couple of bugs that resulted in the hover text incorrectly identifying a symbol as a "type alias". 2020-09-04 15:36:23 -07:00
Eric Traut
97d754e1b5
Added support for py.typed files to distinguish between packages that… (#1007)
* Added support for py.typed files to distinguish between packages that claim to have inlined types versus those that don't. Also added support for "partial" stub packages (a "-stub" package that has a py.typed file that includes the line "partial\n" as described in PEP 561).

* Fixed style issue.

* Removed unnecessary truthy tests for results returned by resolveAbsoluteImport.

Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-09-04 14:55:37 -07:00
Eric Traut
6e9f8795ea Changed command-line version to not print any non-JSON output when "--outputjson" option is used. 2020-09-04 14:52:00 -07:00
Eric Traut
0a65625e03 More documentation improvements. 2020-09-04 14:51:40 -07:00
Eric Traut
4fa40fba75 Minor tweak to documentation. 2020-09-04 14:32:38 -07:00
Eric Traut
6591dafce0 Documented the JSON output when "--outputjson" command-line option is used. 2020-09-04 14:30:14 -07:00
Eric Traut
6c1a285e87 Small cleanup in importResolver. Reordered methods so they are grouped and ordered by public, protected and private. Renamed "_addResultsToCache" to "addResultsToCache" since it is protected. 2020-09-04 11:23:11 -07:00
Eric Traut
60eb2ccad6 Fixed bug that caused the recently-added "discriminated field type narrowing" to be used in cases where it should not. This resulted in types being narrowed inappropriately when a field was typed as a union of literals. 2020-09-03 09:14:23 -07:00
Eric Traut
d1d132dc81 Published 1.1.66 2020-09-02 23:27:24 -07:00
Eric Traut
a2f807905d Fixed broken CLI build by adding back index.js and langserver.index.js. 2020-09-02 23:21:27 -07:00
Jake Bailey
9e231b1292
Extensibility updates in threading and fourslash, add completion context (#995) 2020-09-02 19:01:49 -07:00
Eric Traut
e71ad7d23a Added back the missing "__rootDirectory" global so the CLI can find the typeshed directory. 2020-09-02 18:15:47 -07:00
Eric Traut
240794dc43 Fixed crash in CLI due to change in the interface of the "chalk" dependency. 2020-09-02 18:06:54 -07:00
Eric Traut
f8124d9554 Fixed broken build script in CLI package.json file. 2020-09-02 18:06:18 -07:00
Eric Traut
930c2021c6 Added a check and a general type diagnostic for metaclass conflicts. 2020-09-02 17:35:29 -07:00
Eric Traut
17f0b9e94d Fixed a bug in the Pyright parser. It was not correctly following the Python grammar spec when parsing type annotations, so it generated syntax errors in some cases where that was inappropriate. 2020-09-02 09:16:01 -07:00
Eric Traut
ee4f833005 Fixed default value of reportMissingModuleSource setting in JSON schema. It should be "warning", not "none". 2020-09-02 01:08:40 -07:00
Eric Traut
7fd612ad70 Fixed bug in tokenizer that cause line numbers to be off when an invalid token occurred at the end of a line. 2020-09-02 00:28:36 -07:00
Eric Traut
58a349b50e Added check for raise statements that take an exception class but the class constructor requires one or more arguments. 2020-09-01 21:26:10 -07:00
Eric Traut
e168e338dd Fixed an incorrect diagnostic rule for reportMissingTypeArgument. 2020-09-01 20:52:37 -07:00
Eric Traut
e190d4ddef Fixed handling of scopes for nested classes. The previous logic allowed an inner class to access variables defined in an outer class, which is not permitted. 2020-09-01 20:35:08 -07:00
Eric Traut
9e46548fc5 Added new "reportMissingTypeArgument" diagnostic rule and enabled it by default in "strict" mode. It generates a diagnostic when a generic class or generic type alias is used in an annotation with no type arguments provided. Also fixed a bunch of inaccurate settings defaults in pyright's package.json. 2020-09-01 15:59:31 -07:00
Eric Traut
7f7ff556bc
Suppress the use of "Unnecessary" diagnostic hints (used to display variables and code blocks in gray) if the LSP client claims not to support this tag. (#984)
Co-authored-by: Eric Traut <erictr@microsoft.com>
2020-08-31 14:46:51 -07:00