Skip to content

Commit

Permalink
fix type import
Browse files Browse the repository at this point in the history
  • Loading branch information
eonu committed Jan 12, 2024
1 parent 483d541 commit 9299abd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 17 additions & 2 deletions feud/_internal/_types/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
}

try:
import packaging.version
import pydantic_extra_types

version: packaging.version.Version = packaging.version.parse(
pydantic_extra_types.__version__,
)

from pydantic_extra_types.color import Color
from pydantic_extra_types.coordinate import (
Coordinate,
Expand All @@ -70,7 +77,6 @@
CountryAlpha2,
CountryAlpha3,
CountryNumericCode,
CountryOfficialName,
CountryShortName,
)
from pydantic_extra_types.mac_address import MacAddress
Expand All @@ -89,13 +95,22 @@
CountryAlpha2: click.STRING,
CountryAlpha3: click.STRING,
CountryNumericCode: click.STRING,
CountryOfficialName: click.STRING,
CountryShortName: click.STRING,
MacAddress: click.STRING,
PaymentCardNumber: click.STRING,
PhoneNumber: click.STRING,
ABARoutingNumber: click.STRING,
}

if version >= packaging.version.parse("2.2.0"):
from pydantic_extra_types.ulid import ULID

EXTRA_TYPES[ULID] = click.STRING

if version < packaging.version.parse("2.4.0"):
from pydantic_extra_types.country import CountryOfficialName

EXTRA_TYPES[CountryOfficialName] = click.STRING
except ImportError:
EXTRA_TYPES = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
(t.PaymentCardNumber, click.STRING),
(
t.PaymentCardBrand,
lambda x: isinstance(x, click.Choice)
and x.choices
== ["American Express", "Mastercard", "Visa", "Mir", "other"],
lambda x: isinstance(x, click.Choice) and x.choices,
),
(t.PhoneNumber, click.STRING),
(t.ABARoutingNumber, click.STRING),
Expand Down

0 comments on commit 9299abd

Please sign in to comment.