Skip to content

ForwardRef stub for python 3.6 raises error on MyPy check #1738

@SirTelemak

Description

@SirTelemak

Bug

#1598 introduce stub class for ForwardRef without __init__ for type checking so mypy raise error for ForwardRef
https://github.com/samuelcolvin/pydantic/blob/e985857e5a9ede8d346b010a5a039aa84a089826/pydantic/typing.py#L31-L33
I not pretty sure is this is planned or bug and if this is a bug I can fix it with stub __init__

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

pydantic version: 1.6.1
            pydantic compiled: False
                 install path: \venv\Lib\site-packages\pydantic
               python version: 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)]
                     platform: Windows-10-10.0.18362-SP0
     optional deps. installed: ['typing-extensions', 'email-validator']

test.py

# For python version < 3.7
from pydantic.typing import ForwardRef

ref = ForwardRef('A')

class A:
    ...
mypy test.py
> test.py:3: error: Too many arguments for "ForwardRef"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions