Skip to content
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

Dict[k, v] vs dict[k, v] (!) #521

Closed
munael opened this issue Oct 26, 2020 · 5 comments
Closed

Dict[k, v] vs dict[k, v] (!) #521

munael opened this issue Oct 26, 2020 · 5 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@munael
Copy link

munael commented Oct 26, 2020

Environment data

  • Language Server version: 2020.10.2
  • OS and version: Windows 10 20H2
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda with Python 3.7.7

Expected behaviour

Either:

  1. No errors, if dict[k, v] is meant to be supported.
  2. An error on type expressions of the form x: dict[k, v] for being invalid.
    1. And: never infer dict[k, v] as a type.

Actual behaviour

x: Dict[str, str] = {'foo': 'bar'}
x = dict(x)
y: dict[str, str] = {'foo': 'bar'}
x = y
PyLance:
  "dict[str, str]" is incompatible with "Dict[str, str]"Pylance (reportGeneralTypeIssues)

Where:

  1. At line (1) x has type Dict[]
  2. At line (2) dict(x) has type dict[]
  3. Same at line (3) then (4) for y

Logs

Logic bug.

Code Snippet / Additional information

This template feels sort of inverted. Maybe merge "Code" and "Actual Behavior" and place them before "Expected Behavior"?

@erictraut
Copy link
Contributor

I'm tracking the same bug here: microsoft/pyright#1120. The problem is that I'm not able to repro the problem, and it appears to be sporadic. I assume it has to do with some aspect of the type analyzers internal caching mechanism.

@judej judej added the bug Something isn't working label Oct 26, 2020
@github-actions github-actions bot removed the triage label Oct 26, 2020
@erictraut
Copy link
Contributor

I found and fixed the root cause of this problem. The fix will be in the next release.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 3, 2020
@ElijahSink
Copy link

ElijahSink commented Nov 3, 2020

I've noticed the same issue with list vs List.
image

@jakebailey
Copy link
Member

@ElijahSink I believe that'll also be fixed.

@jakebailey
Copy link
Member

This issue has been fixed in version 2020.11.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#2020110-4-november-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

5 participants