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

strict mode in zip causes extra type errors #1909

Closed
Molkree opened this issue Oct 6, 2021 · 7 comments
Closed

strict mode in zip causes extra type errors #1909

Molkree opened this issue Oct 6, 2021 · 7 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@Molkree
Copy link

Molkree commented Oct 6, 2021

Environment data

  • Language Server version: v2021.9.4
  • OS and version: Win10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10

Expected behaviour

No error warnings.

Actual behaviour

Below code doesn't cause any warnings:

names = ["John", "Jess"]
ages = [20]
for name, age in zip(names, ages):
    pass

However when using the new strict mode for zip function added in Python 3.10 (PEP 618):

names = ["John", "Jess"]
ages = [20]
for name, age in zip(names, ages, strict=True):
    pass

I am getting 3 errors now:

  • 1 on zip function itself, this appears with type checking at basic
    No overloads for "__new__" match the provided arguments
    Argument types: (list[str], list[int], Literal[True])
  • strict type checking also introduces errors for each unpacked variable:
    Type of "name"/"age" is unknown

image

Code Snippet / Additional information

Additionally, strict is not in the candidates list when typing in zip.

@github-actions github-actions bot added the triage label Oct 6, 2021
@jakebailey
Copy link
Member

The stub for zip is here: https://github.com/python/typeshed/blob/master/stdlib/builtins.pyi#L1327

It appears as though it hasn't yet been updated for PEP 618 yet.

@judej judej added the waiting for upstream Waiting for upstream to release a fix label Oct 6, 2021
@github-actions github-actions bot removed the triage label Oct 6, 2021
@Molkree
Copy link
Author

Molkree commented Oct 6, 2021

This was just fixed in typeshed.

@jakebailey
Copy link
Member

Thanks. This will be included in our next release.

@jakebailey jakebailey added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed waiting for upstream Waiting for upstream to release a fix labels Oct 6, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.10.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#2021100-6-october-2021

@Molkree
Copy link
Author

Molkree commented Oct 7, 2021

I no longer see any errors when using strict however it is still not in the candidates list.

image

Not sure if it's on the typeshed or pylance side and I understand it's not really the initial issue so I can open a new one.

@jakebailey
Copy link
Member

That seems like a bug in the completion provider; zip is unique because it's signatures are provided by __new__ and they are a little duplicated thanks to the lack of variadics. It could be that we don't handle this right; I did notice that signature help didn't work correctly with zip too.

Would you mind filing a new issue?

@Molkree
Copy link
Author

Molkree commented Oct 7, 2021

Would you mind filing a new issue?

Sure, I've opened #1912.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

3 participants