question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type hint inconsistency for `shape`

See original GitHub issue

image

gave this warning in VS Code

Argument of type "tuple[int, int]" cannot be assigned to parameter "shape" of type "int | Tuple[()] | Tuple[int]" in function "Zeros"
  Type "tuple[int, int]" cannot be assigned to type "int | Tuple[()] | Tuple[int]"
    "tuple[int, int]" is incompatible with "int"
    Tuple size mismatch; expected 0 but received 2
    Tuple size mismatch; expected 1 but received 2PylancereportGeneralTypeIssues

Need to make shape type hint accept a tuple with any number of integer arguments.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mhostettercommented, Jan 24, 2022

@iyanmv please keep opening issues or commenting when you find weird/strange type hint warnings/errors. That’s really helpful for me! 👍

1reaction
iyanmvcommented, Jan 24, 2022

Never mind… I think PyCharm needed some extra time when changing from one interpreter to another. Sequence[int] works for me as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing Good Code - Python Like You Mean It
This is a good place to embellish the type information with pertinent information that is not conveyed by the formal type-hints. For example,...
Read more >
PEP 484 Type Annotations (feature request) #12345 - GitHub
System information N/A Describe the problem Background PEP 484 [1] added support for type hints in Python. These are purely annotations and ...
Read more >
Understanding type annotation in Python - LogRocket Blog
With type hints, you can annotate variables and functions with datatypes. Tools like mypy, pyright, pytypes, or pyre perform the functions of ...
Read more >
Python's “type hints” are a bit of a disappointment to me
Honestly, I've recently written a few 300-500 line programs in Python using type hints and I'm never going back. And I'm not even...
Read more >
Type annotations for *args and **kwargs - Stack Overflow
Arbitrary argument lists can as well be type annotated, ... *args always means 0 or more, and can't be limited by type hints...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found