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

Empty tuple is incompatible with Tuple[Any, ...] #69

Closed
jolaf opened this issue Aug 26, 2019 · 4 comments
Closed

Empty tuple is incompatible with Tuple[Any, ...] #69

jolaf opened this issue Aug 26, 2019 · 4 comments

Comments

@jolaf
Copy link

jolaf commented Aug 26, 2019

The following code:

from typing import Any, Tuple

from pytypes import TypeChecker

def f() -> Tuple[Any, ...]:
    return ()

with TypeChecker():
    f()
    print("OK")

fails as follows:

$ python3 Test.py
Traceback (most recent call last):
  File "Test.py", line 9, in <module>
    f()
  File "Test.py", line 6, in f
    return ()
pytypes.exceptions.ReturnTypeError: 
  __main__.f
  returned incompatible type:
Expected: Tuple[Any]
Received: Tuple[]
@Stewori
Copy link
Owner

Stewori commented Aug 26, 2019

Okay, pytypes seems to expect here a Tuple with at least one element. I think the convention for Tuple varargs changed some times. This will require a look how it finally turned out.

@Stewori
Copy link
Owner

Stewori commented Sep 15, 2019

Okay, this was not due to changes in typing semantics: tuple ellipsis worked the same all the time. This issue has a two-fold cause:

  • When matching the tuple arags with types from a stubfile, the ellipsis property of the tuple was not preserved.

  • while handled correctly in is_subtype, I somehow forgot tuple ellipsis handling when I wrote is_of_type, which accellerates type checking for certain types.

@Stewori Stewori added the bug label Sep 15, 2019
@Stewori Stewori added the fixed label Sep 15, 2019
@jolaf
Copy link
Author

jolaf commented Mar 11, 2020

Is there expected a release containing this and other fixes?

@Stewori
Copy link
Owner

Stewori commented Mar 11, 2020

See #40 (bottom). I hope to find time around eastern, no promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants