-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression of type 'Union[str, bytes]' cannot be assigned to declared type 'str' #103
Labels
addressed in next version
Issue is fixed and will appear in next published version
bug
Something isn't working
Comments
Thanks for the bug report. This will be fixed in the next version. |
erictraut
added
bug
Something isn't working
addressed in next version
Issue is fixed and will appear in next published version
labels
Apr 30, 2019
This is now fixed in 1.0.20, which I just published. |
heejaechang
added a commit
to heejaechang/pyright
that referenced
this issue
Feb 20, 2020
* Squashed 'server/pyright/' changes from 9521693..b1e0ff8 b1e0ff8 made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (microsoft#507) git-subtree-dir: server/pyright git-subtree-split: b1e0ff8 * Squashed 'server/pyright/' changes from b1e0ff8..1844ea2 1844ea2 Published 1.1.24 1e51e7f Added support for user-defined generic type aliases. ded73fe Fixed a condition where the literal portion of a type was improperly removed. This affected imported type aliases in some contexts. 816a110 Fixed the handling of bidirectional type inference for cases involving lists with a declared entry type. 4900234 Published 1.1.23 25758b8 Fixed bug in import resolver. It was incorrectly returning implicit imports for "import X" or "import X as Y" statements. e7b221e Improved parse recovery and error messages for syntax that was previously valid in Python 2 but was made obsolete in Python 3. 3c81765 Reverted default value of 'reportMissingTypeStubs' setting from 'warning' to 'none'. 6ad6ce2 Fixed minor formatting issue in error message. a97b202 Fixed a hole in protocol type checking. The type checker wasn't properly handling protocol classes that derived from other classes. fdb4546 Simplified logic in canAssignClass. 998c9a0 Moved protocol and typed dict logic out of canAssignClass function for clarity. 8ed0f3b Updated dataclass analysis logic so it can handle circular type references in dataclass definitions. 0675dcc Added comment to eliminate eslint warning in webpack.config-server.js. 7411bc8 Renamed _undeclaredType in symbol.ts to _synthesizedType for clarity. c3af4d6 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. 2230a77 Handled special case in getCallSignatureInfo for data classes so function signature suggestions work. d3221ca Made a few small improvements to documentation. 3661fe3 Published 1.1.22 679102a Fixed regression that broke "package" build script. 80cbf2a Made commands enum "const" so file doesn't need to be included in webpack. da4a9a6 Added type narrowing support for built-in "callable" call. d379117 Fixed bug in handling of "cast" function when type is specified within a string literal. 8e1bf2b 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. 7afbbca 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. bc2c8d4 Added eslint plugin for enforcing and fixing import sort order and groupings. Fixed all source files that are nonconformant. f866c03 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. 8bed8ed Added minor perf improvement in type evaluator - avoiding finding the correct overload function twice. b623cb0 Fixed bug in type evaluator where it not properly handling properties within protocol classes. 094bd03 Switched all non-test code to use assert and fail methods from common/debug rather than the node assert module. 46e792c 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. e6396e3 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. ec63949 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. 04a01c7 Merge pull request microsoft#510 from microsoft/erictr/debugging f6bb03b Fixed debug builds. Recent changes broke debugging (setting breakpoints, etc.). 2aa319f 3 fourslash improvement to support custom lib/typeshed folders (microsoft#514) 50b0d32 added a hook to ImportResolver for custom importing logic. (microsoft#515) de41104 Merge pull request microsoft#511 from microsoft/erictr/clean c57fafd Fixed ordering of build script — npm install needs to happen before clean because the latter depends on a node module. 46bb90c Added "clean" command to build script. Fixed bug in build script for debug version of server. f3a4aed Revert "Added "clean" build command that deletes artifacts from previous build actions." e22c661 Added "clean" build command that deletes artifacts from previous build actions. a5e3b37 Merge pull request microsoft#509 from heejaechang/fixRootDirectoryIssue bdcd372 previously added assert was using wrong path (__dirname rather than __dirname/..) git-subtree-dir: server/pyright git-subtree-split: 1844ea2 * Squashed 'server/pyright/' changes from 1844ea2..ef9d92b ef9d92b Fixed file name of test case. It was failing on Linux because file system is case sensitive. f94d7a0 Removed tslint disable statements and added eslint disable to pyright.ts to eliminate false linting error. git-subtree-dir: server/pyright git-subtree-split: ef9d92b
heejaechang
added a commit
to heejaechang/pyright
that referenced
this issue
Nov 3, 2021
* Squashed 'server/pyright/' changes from 9521693..b1e0ff8 b1e0ff8 made reportMissingTypeStub diagnostics warning by default and some refactoring around code actions. (microsoft#507) git-subtree-dir: server/pyright git-subtree-split: b1e0ff8 * Squashed 'server/pyright/' changes from b1e0ff8..1844ea2 1844ea2 Published 1.1.24 1e51e7f Added support for user-defined generic type aliases. ded73fe Fixed a condition where the literal portion of a type was improperly removed. This affected imported type aliases in some contexts. 816a110 Fixed the handling of bidirectional type inference for cases involving lists with a declared entry type. 4900234 Published 1.1.23 25758b8 Fixed bug in import resolver. It was incorrectly returning implicit imports for "import X" or "import X as Y" statements. e7b221e Improved parse recovery and error messages for syntax that was previously valid in Python 2 but was made obsolete in Python 3. 3c81765 Reverted default value of 'reportMissingTypeStubs' setting from 'warning' to 'none'. 6ad6ce2 Fixed minor formatting issue in error message. a97b202 Fixed a hole in protocol type checking. The type checker wasn't properly handling protocol classes that derived from other classes. fdb4546 Simplified logic in canAssignClass. 998c9a0 Moved protocol and typed dict logic out of canAssignClass function for clarity. 8ed0f3b Updated dataclass analysis logic so it can handle circular type references in dataclass definitions. 0675dcc Added comment to eliminate eslint warning in webpack.config-server.js. 7411bc8 Renamed _undeclaredType in symbol.ts to _synthesizedType for clarity. c3af4d6 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. 2230a77 Handled special case in getCallSignatureInfo for data classes so function signature suggestions work. d3221ca Made a few small improvements to documentation. 3661fe3 Published 1.1.22 679102a Fixed regression that broke "package" build script. 80cbf2a Made commands enum "const" so file doesn't need to be included in webpack. da4a9a6 Added type narrowing support for built-in "callable" call. d379117 Fixed bug in handling of "cast" function when type is specified within a string literal. 8e1bf2b 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. 7afbbca 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. bc2c8d4 Added eslint plugin for enforcing and fixing import sort order and groupings. Fixed all source files that are nonconformant. f866c03 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. 8bed8ed Added minor perf improvement in type evaluator - avoiding finding the correct overload function twice. b623cb0 Fixed bug in type evaluator where it not properly handling properties within protocol classes. 094bd03 Switched all non-test code to use assert and fail methods from common/debug rather than the node assert module. 46e792c 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. e6396e3 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. ec63949 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. 04a01c7 Merge pull request microsoft#510 from microsoft/erictr/debugging f6bb03b Fixed debug builds. Recent changes broke debugging (setting breakpoints, etc.). 2aa319f 3 fourslash improvement to support custom lib/typeshed folders (microsoft#514) 50b0d32 added a hook to ImportResolver for custom importing logic. (microsoft#515) de41104 Merge pull request microsoft#511 from microsoft/erictr/clean c57fafd Fixed ordering of build script — npm install needs to happen before clean because the latter depends on a node module. 46bb90c Added "clean" command to build script. Fixed bug in build script for debug version of server. f3a4aed Revert "Added "clean" build command that deletes artifacts from previous build actions." e22c661 Added "clean" build command that deletes artifacts from previous build actions. a5e3b37 Merge pull request microsoft#509 from heejaechang/fixRootDirectoryIssue bdcd372 previously added assert was using wrong path (__dirname rather than __dirname/..) git-subtree-dir: server/pyright git-subtree-split: 1844ea2 * Squashed 'server/pyright/' changes from 1844ea2..ef9d92b ef9d92b Fixed file name of test case. It was failing on Linux because file system is case sensitive. f94d7a0 Removed tslint disable statements and added eslint disable to pyright.ts to eliminate false linting error. git-subtree-dir: server/pyright git-subtree-split: ef9d92b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
addressed in next version
Issue is fixed and will appear in next published version
bug
Something isn't working
Describe the bug
Expression of type 'Union[str, bytes]' cannot be assigned to declared type 'str'
Type 'bytes' cannot be assigned to type 'str'.
'Type[bytes]' is incompatible with 'Type[str]'
To Reproduce
Expected behavior
No problems reported
Screenshots or Code
VS Code extension or command-line
I am running pyright as a VS Code extension 1.0.19
Additional context
Thank you so much for your great work!
The text was updated successfully, but these errors were encountered: