4040'LU00000987ABC'
4141"""
4242
43+ from __future__ import annotations
44+
4345from stdnum .eu .vat import MEMBER_STATES
4446from stdnum .exceptions import *
45- from stdnum .util import clean , get_cc_module , get_soap_client
47+ from stdnum .util import (
48+ NumberValidationModule , clean , get_cc_module , get_soap_client )
49+
50+
51+ TYPE_CHECKING = False
52+ if TYPE_CHECKING : # pragma: no cover (typechecking only import)
53+ from typing import Any
4654
4755
4856_country_modules = dict ()
5159"""The WSDL URL of the System for Exchange of Excise Data (SEED)."""
5260
5361
54- def _get_cc_module (cc ) :
62+ def _get_cc_module (cc : str ) -> NumberValidationModule | None :
5563 """Get the Excise number module based on the country code."""
5664 cc = cc .lower ()
5765 if cc not in MEMBER_STATES :
@@ -61,14 +69,14 @@ def _get_cc_module(cc):
6169 return _country_modules [cc ]
6270
6371
64- def compact (number ) :
72+ def compact (number : str ) -> str :
6573 """Convert the number to the minimal representation. This strips the number
6674 of any valid separators and removes surrounding whitespace."""
6775 number = clean (number , ' ' ).upper ().strip ()
6876 return number
6977
7078
71- def validate (number ) :
79+ def validate (number : str ) -> str :
7280 """Check if the number is a valid Excise number."""
7381 number = clean (number , ' ' ).upper ().strip ()
7482 cc = number [:2 ]
@@ -80,19 +88,22 @@ def validate(number):
8088 return number
8189
8290
83- def is_valid (number ) :
91+ def is_valid (number : str ) -> bool :
8492 """Check if the number is a valid Excise number."""
8593 try :
8694 return bool (validate (number ))
8795 except ValidationError :
8896 return False
8997
9098
91- def check_seed (number , timeout = 30 ): # pragma: no cover (not part of normal test suite)
99+ def check_seed (
100+ number : str ,
101+ timeout : float = 30 ,
102+ ) -> dict [str , Any ]: # pragma: no cover (not part of normal test suite)
92103 """Query the online European Commission System for Exchange of Excise Data
93104 (SEED) for validity of the provided number. Note that the service has
94105 usage limitations (see the VIES website for details). The timeout is in
95106 seconds. This returns a dict-like object."""
96107 number = compact (number )
97108 client = get_soap_client (seed_wsdl , timeout )
98- return client .verifyExcise (number )
109+ return client .verifyExcise (number ) # type: ignore[no-any-return]
0 commit comments