Skip to content

CountryAlpha2 class example use-case results in mypy error #316

Description

@TeaDrinkingProgrammer

When the documented example use-case of CountryAlpha2 is used with Mypy, it results in a type error.

Code:

from pydantic import BaseModel

from pydantic_extra_types.country import CountryAlpha2


class Product(BaseModel):
    made_in: CountryAlpha2


product = Product(made_in='ES')
print(product)
# > made_in='ES'

Results in:

Argument "made_in" to "Product" has incompatible type "str"; expected "CountryAlpha2" [arg-type]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions