Commit Graph

1621 Commits

Author SHA1 Message Date
Eric Traut
3c8176542a Reverted default value of 'reportMissingTypeStubs' setting from 'warning' to 'none'. 2020-02-17 16:31:10 -07:00
Eric Traut
6ad6ce2b66 Fixed minor formatting issue in error message. 2020-02-17 15:03:45 -07:00
Eric Traut
a97b20226c Fixed a hole in protocol type checking. The type checker wasn't properly handling protocol classes that derived from other classes. 2020-02-17 15:01:21 -07:00
Eric Traut
fdb4546b94 Simplified logic in canAssignClass. 2020-02-17 14:42:13 -07:00
Eric Traut
998c9a0074 Moved protocol and typed dict logic out of canAssignClass function for clarity. 2020-02-17 14:40:03 -07:00
Eric Traut
8ed0f3b1e7 Updated dataclass analysis logic so it can handle circular type references in dataclass definitions. 2020-02-17 11:51:00 -07:00
Eric Traut
0675dcc8db Added comment to eliminate eslint warning in webpack.config-server.js. 2020-02-17 11:49:32 -07:00
Eric Traut
7411bc80af Renamed _undeclaredType in symbol.ts to _synthesizedType for clarity. 2020-02-17 11:01:26 -07:00
Eric Traut
c3af4d6a95 Fixed a bug in the f-string parsing code, which didn't correctly handle the case where the "!=" token was used in an f-string expression. 2020-02-17 10:55:42 -07:00
Eric Traut
2230a7736b Handled special case in getCallSignatureInfo for data classes so function signature suggestions work. 2020-02-17 01:17:34 -07:00
Eric Traut
d3221ca343 Made a few small improvements to documentation. 2020-02-17 01:16:30 -07:00
Eric Traut
3661fe3d5e Published 1.1.22 2020-02-15 13:59:08 -07:00
Eric Traut
679102a400 Fixed regression that broke "package" build script. 2020-02-15 13:57:27 -07:00
Eric Traut
80cbf2add8 Made commands enum "const" so file doesn't need to be included in webpack. 2020-02-15 13:57:00 -07:00
Eric Traut
da4a9a66da Added type narrowing support for built-in "callable" call. 2020-02-15 13:15:30 -07:00
Eric Traut
d379117c19 Fixed bug in handling of "cast" function when type is specified within a string literal. 2020-02-15 11:21:53 -07:00
Eric Traut
8e1bf2b74e Fixed bug in type check logic that determines whether a class conforms to a Protocol. It was not properly taking into account instance variables within the class. 2020-02-15 10:48:55 -07:00
Eric Traut
7afbbcaadf Added error reporting for instance and class variables within methods declared in a Protocol class. PEP 544 indicates that these should be flagged as an error. 2020-02-15 10:22:52 -07:00
Eric Traut
bc2c8d455d Added eslint plugin for enforcing and fixing import sort order and groupings. Fixed all source files that are nonconformant. 2020-02-15 02:00:51 -07:00
Eric Traut
f866c033b8 Fixed translation of a heterogenous tuple into an iterator. The resulting iterator needs to have a type argument created from a union of the heterogeneous tuple entries. 2020-02-15 01:21:55 -07:00
Eric Traut
8bed8ed079 Added minor perf improvement in type evaluator - avoiding finding the correct overload function twice. 2020-02-15 01:03:28 -07:00
Eric Traut
b623cb0389 Fixed bug in type evaluator where it not properly handling properties within protocol classes. 2020-02-15 00:59:00 -07:00
Eric Traut
094bd03019 Switched all non-test code to use assert and fail methods from common/debug rather than the node assert module. 2020-02-15 00:31:32 -07:00
Eric Traut
46e792c67d Fixed bug in type evaluator relating to type var matching for function calls. The code now "locks" the type var map after the first pass. In the second pass, it verifies that the arguments are compatible with the types associated with the (now-locked) type vars. 2020-02-15 00:16:59 -07:00
Eric Traut
e6396e35ef Fixed another bug that affects the debug version of pyright. The way I was computing debugTypeshedPath left ".." in the path, so later path comparisons failed. 2020-02-14 10:14:59 -07:00
Eric Traut
ec639491ae Fixed bug in binder logic that resulted in infinite recursion in the type evaluator. It occurred in the case where the target of an assignment was a tuple and the elements in the tuple depended on assignment ordering. The binder was not assigning the correct control flow nodes to the individual elements of the target tuple. 2020-02-14 09:27:47 -07:00
Eric Traut
04a01c767f
Merge pull request #510 from microsoft/erictr/debugging
Fixed debug builds.
2020-02-12 23:10:26 -07:00
Eric Traut
f6bb03bc50 Fixed debug builds. Recent changes broke debugging (setting breakpoints, etc.). 2020-02-12 22:58:55 -07:00
Heejae Chang
2aa319fd8f
3 fourslash improvement to support custom lib/typeshed folders (#514)
* 3 fourslash improvement to support custom lib/typeshed folders

1. added an ability to add library code directly in fourslash test file.
2. added an ability to mount different folder as typeshed folder in virtual file system in fourslash test.
3. added an ability to mount multiple folders in virtual file system.

* addressed PR feedbacks
2020-02-12 20:12:54 -08:00
Heejae Chang
50b0d324a1
added a hook to ImportResolver for custom importing logic. (#515) 2020-02-12 17:29:39 -08:00
Eric Traut
de41104883
Merge pull request #511 from microsoft/erictr/clean
Added "clean" command to build script. Fixed bug in build script for …
2020-02-12 12:03:11 -07:00
Eric Traut
c57fafdc5f Fixed ordering of build script — npm install needs to happen before clean because the latter depends on a node module. 2020-02-11 23:23:08 -07:00
Eric Traut
46bb90cca6 Added "clean" command to build script. Fixed bug in build script for debug version of server. 2020-02-11 18:38:00 -07:00
Eric Traut
f3a4aed6ae Revert "Added "clean" build command that deletes artifacts from previous build actions."
This reverts commit e22c661c3e.
2020-02-11 18:23:21 -07:00
Eric Traut
e22c661c3e Added "clean" build command that deletes artifacts from previous build actions. 2020-02-11 17:47:55 -07:00
Eric Traut
a5e3b377f7
Merge pull request #509 from heejaechang/fixRootDirectoryIssue
previously added assert was using wrong path (__dirname rather than _…
2020-02-11 17:19:06 -07:00
HeeJae Chang
bdcd372014 previously added assert was using wrong path (__dirname rather than __dirname/..)
fixed the assert and added comments indicating what is supposed to point what.
2020-02-11 15:31:23 -08:00
Heejae Chang
b1e0ff81dd
made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (#507)
* enable generate type stub diagnostic (and hence code action) on by default as "warning"

* refactored code action code a bit
2020-02-11 00:39:21 -08:00
Heejae Chang
9521693b9c
fixed regex issue on linux/mac (#503)
my previous work to make pyright test to pass on windows broke linux and mac scenarios.

this should fix the issues.
2020-02-07 12:17:52 -08:00
Heejae Chang
b9bc57306a
fixed bunch of tslint issue and refactoring on how command handling works (#502)
* fixes many es/tslint style warnings
* Remove map inside map
2020-02-06 12:33:09 -08:00
Mikhail Arkhipov
c08248902e
Merge pull request #501 from heejaechang/fourslashRI
ported typescript fourslash test framework to pyright
2020-02-06 11:32:36 -08:00
HeeJae Chang
59c693b65a ported typescript fourslash test framework to pyright
this PR consists of 3 main changes.

refactoring on pyright, 2. bunch of helper methods in src/common, 3. fourslash related codes in src/test
...

for 1. refactoring.

it has 2 refactorings on pyright and that affects many pyright code. which made file counts of this PR high.

first refactoring is rename of DiagnosticTextPosition and related types to Position/Range and move them out from diagnostics.ts to textRange.ts.

this is done since I needed line column and it is not diagnostic specific concept.

second one is introducing virtual file system to pyright (server/src/common/vfs.ts).

this is needed since I needed pyright to run over virtual file system constructed from fourslash files.
also, after this, nobody in pyright should interact with file system directly (no import * from "fs").

...

for 2. bunch of helper methods in src/common

it is just bunch of helper methods over path, collections, strings and etc fourslash test framework was using. mostly about string, path comparisons, adding/removing collections without caring about corner cases and etc.

...

for 3. fourslash related codes in src/test

all code related to it should be under src/test/harness and actual tests will be in src/test/fourslash

fourslash test framework is consist of 5 components

virtual file system - this is a file system (server/src/tests/harness/vfs/filesystem.ts) emulating real one. it is a standalone lib people can use for other purpose as well. see (server/src/tests/filesystem.test.ts) on how to use it.

fourslash test reader/parser
it reads fourslash file like (server/src/tests/fourslash/dataclass1.fourslash.ts) or (server/src/tests/fourSlashParser.test.ts) and return FourSlashData that contains source + markup information.
this is also a standalone library one can use on other scenarios just for markups.

testState
it maintain current test states. such as what file is opened, where the caret position is, what is current active files, selection is. and hold pyright program, virtual file system and etc. this will be given to a fourslash test file when the test run. and people can interact with it to manipulate or verify test results. see (server/src/tests/testState.test.ts) for what it currently supports. this should keep updated as we add new tests and new test ability.
one thing to remember is that, TestState is what run at runtime (implementation), but for editting, fourslash.ts (declaration) (server/src/tests/fourslash/fourslash.ts) is the one that is used.
that is why there is reference path="fourslash.ts" at the top of each fourslash test file (ex, server/src/tests/fourslash/dataclass1.fourslash.ts). because of that, it is important to put declaration in fourslash.ts if one added new functionality in TestState.

fourslash test runner
this puts everything together and run given fourslash markup strings. to learn how it actually run code. see (server/src/tests/harness/fourslash/runner.ts).
basically, it gets sources (python code) out of fourslash string, and construct virtual file system and connect it to pyright using TestState and then compile the given fourslash markup string since it is actually pure typescript code and then wrapped the compiled javascript code under function and eval the code and run it with TestState as argument. the reference path=".." trick works since it gets ignored within method body as a regular comment.
this is also a standalone lib people can use in other way if wants. see (

server/src/tests/testState.test.ts

test('VerifyDiagnosticsTest1', () => {
) on how to use it.

jest test suite
this connects fourslash test framework to jest. it basically read fourslash test files in **/test/fourslahs/*.fourslash.ts and register it to jest and run them with the fourslash test runner.
(server/src/tests/fourSlashRunner.test.ts)
...

PR also includes some misc changes such as ignoring eslint on fourslash.ts files. or js/ts formatting rule such as putting space after template string since that seems what pyright currently has as a code style. and this also includes some of checker.test.ts converted to fourslahst test to show differences. and debugger launch settings for fourslash tests.

...

how to run fourslash tests.

on command line, if one runs jest tests (ex, npm run test), it will run fourslash tests as well. in vscode, if users choose vscode-jest-tests, it will run fourslash tests as well. if user opens fourslash.ts file and then select fourslash current file in debugger configuration and F5, vscode will run only that fourslash test file.
2020-02-05 13:28:04 -08:00
Mikhail Arkhipov
fc8f190c6c Fix debugging of referenced projects 2020-02-04 23:46:06 -08:00
Eric Traut
634533f207 Changed build script to build server before client, which is needed because of a recent change made by Mikhail. 2020-02-04 22:27:45 -08:00
Eric Traut
d7ded12962 Made small improvements to internals docs. 2020-02-04 13:08:58 -08:00
Mikhail Arkhipov
cfc5c92fe6
Merge pull request #499 from MikhailArkhipov/commands
Unify command identifiers
2020-02-04 12:11:30 -08:00
MikhailArkhipov
d7ed5c1ecd Delete comma 2020-02-04 11:58:04 -08:00
MikhailArkhipov
40c62216be Fix webpack 2020-02-04 11:31:45 -08:00
MikhailArkhipov
88492b956b Unify command identifiers 2020-02-03 15:20:23 -08:00
Eric Traut
6a2904c952
Merge pull request #498 from microsoft/erictr/typings
494: Moved code that sets default typingsPath value so it's executed …
2020-02-01 09:15:57 -08:00