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+ TYPE_CHECKING = False
51+ if TYPE_CHECKING : # pragma: no cover (typechecking only import)
52+ from typing import Any
4653
4754
4855_country_modules = dict ()
5158"""The WSDL URL of the System for Exchange of Excise Data (SEED)."""
5259
5360
54- def _get_cc_module (cc ) :
61+ def _get_cc_module (cc : str ) -> NumberValidationModule | None :
5562 """Get the Excise number module based on the country code."""
5663 cc = cc .lower ()
5764 if cc not in MEMBER_STATES :
@@ -61,14 +68,14 @@ def _get_cc_module(cc):
6168 return _country_modules [cc ]
6269
6370
64- def compact (number ) :
71+ def compact (number : str ) -> str :
6572 """Convert the number to the minimal representation. This strips the number
6673 of any valid separators and removes surrounding whitespace."""
6774 number = clean (number , ' ' ).upper ().strip ()
6875 return number
6976
7077
71- def validate (number ) :
78+ def validate (number : str ) -> str :
7279 """Check if the number is a valid Excise number."""
7380 number = clean (number , ' ' ).upper ().strip ()
7481 cc = number [:2 ]
@@ -80,19 +87,22 @@ def validate(number):
8087 return number
8188
8289
83- def is_valid (number ) :
90+ def is_valid (number : str ) -> bool :
8491 """Check if the number is a valid Excise number."""
8592 try :
8693 return bool (validate (number ))
8794 except ValidationError :
8895 return False
8996
9097
91- def check_seed (number , timeout = 30 ): # pragma: no cover (not part of normal test suite)
98+ def check_seed (
99+ number : str ,
100+ timeout : float = 30
101+ ) -> dict [str , Any ]: # pragma: no cover (not part of normal test suite)
92102 """Query the online European Commission System for Exchange of Excise Data
93103 (SEED) for validity of the provided number. Note that the service has
94104 usage limitations (see the VIES website for details). The timeout is in
95105 seconds. This returns a dict-like object."""
96106 number = compact (number )
97107 client = get_soap_client (seed_wsdl , timeout )
98- return client .verifyExcise (number )
108+ return client .verifyExcise (number ) # type: ignore[no-any-return]
0 commit comments