Closed
Description
Bug Report
mypy fails when an alias is used but not when the long form is used
To Reproduce
- import botostubs
import botostubs
- Create type alias at top of file but but below the import
# Type Alias Vpc = botostubs.EC2.Ec2Resource.Vpc
- assign alias to a functions return type
def find_vpc(vpc_name: str) -> Vpc:
- Run mypy
error: Variable "my_package.utils.aws.Vpc" is not valid as a type
Expected Behavior
I expected that I would be able to use the type alias. When I use the long form.
def find_vpc(vpc_name: str) -> botostubs.EC2.Ec2Resource.Vpc:
I do not get the error when I run mypy
Actual Behavior
It errors when using the alias.
Your Environment
- Mypy version used:
mypy 0.800
mypy-extensions 0.4.3
- Mypy command-line flags: I just pass the directory
- Mypy configuration options from
mypy.ini
(and other config files):
[mypy]
[mypy-nox.*,pytest,docker.*,git.*,boto3.*,botostubs.*,botocore.*]
ignore_missing_imports = True
- Python version used: 3.9
- Operating system and version: Windows 10 WSL
Not sure if it means anything but my IDE (visual studio code with pylance) works with the alias: