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

Inline union assigned to type alias produces error #14302

Closed
tcobbs-bentley opened this issue Dec 15, 2022 · 4 comments
Closed

Inline union assigned to type alias produces error #14302

tcobbs-bentley opened this issue Dec 15, 2022 · 4 comments
Labels
bug mypy got something wrong topic-pep-585 PEP 585 (builtin generics) topic-type-alias TypeAlias and other type alias issues

Comments

@tcobbs-bentley
Copy link

Bug Report
The following code produces an error when using mypy as a linter in Visual Studio Code:

Test = tuple[str, str] | str

(Using pylint as a linter, the above code does not produce an errror.)

The following (equivalent, AFAIK) code does not produce an error when using mypy as a linter:

Test = Union[tuple[str, str], str]

For reasons that aren't really clear, the following code does not produce an error (even though it seems similar to the code that produces an error):

SQLiteDescription = tuple[tuple[str, None, None, None, None, None, None], ...] | Any

For reference, the error (in Visual Studio Code) is this:

[{
	"resource": "/Users/travis/Dev/itwin/mobile-samples/cross-platform/startuptimes/startuptimes.py",
	"owner": "python",
	"code": "error",
	"severity": 8,
	"message": "Type application has too many types (1 expected)  [misc]",
	"source": "mypy",
	"startLineNumber": 23,
	"startColumn": 8,
	"endLineNumber": 23,
	"endColumn": 8
}]

(A clear and concise description of what the bug is.)

To Reproduce

  1. Install Visual Studio Code
  2. Install Microsoft's Python plugin
  3. Open a Python file.
  4. Use the Python: Select Linter command (from F1 command palette) to select mypy as the linter.
  5. Install mypy if prompted to do so.
  6. Include the following code in your Pyton file:
Test = tuple[str, str] | str

Expected Behavior

The code should be accepted by mypy.

Actual Behavior

mypy gives the following error:

Type application has too many types (1 expected)  [misc]

Your Environment

  • Mypy version used: 0.991
  • Mypy command-line flags: Unknown (linter in VS Code)
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.10.6
@tcobbs-bentley tcobbs-bentley added the bug mypy got something wrong label Dec 15, 2022
@AlexWaygood AlexWaygood added topic-pep-585 PEP 585 (builtin generics) topic-type-alias TypeAlias and other type alias issues labels Dec 15, 2022
@AlexWaygood
Copy link
Member

Duplicate of #11098

@AlexWaygood AlexWaygood marked this as a duplicate of #11098 Dec 15, 2022
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2022
@AlexWaygood
Copy link
Member

(It's already fixed on mypy master; the fix will be included in the next release, mypy 1.0.)

@tcobbs-bentley
Copy link
Author

Sorry, I didn't search closed issues.

@AlexWaygood
Copy link
Member

No worries! Follow #13685 for updates on when the next release will be coming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-585 PEP 585 (builtin generics) topic-type-alias TypeAlias and other type alias issues
Projects
None yet
Development

No branches or pull requests

2 participants