55############
66
77
8- def sieve (dirty ): # type: ( str) -> str
8+ def sieve (dirty : str ) -> str :
99 """
1010 Removes specific symbols from a CNPJ (Brazilian Company Registration
1111 Number) string.
@@ -33,7 +33,7 @@ def sieve(dirty): # type: (str) -> str
3333 return "" .join (filter (lambda char : char not in "./-" , dirty ))
3434
3535
36- def remove_symbols (dirty ): # type: ( str) -> str
36+ def remove_symbols (dirty : str ) -> str :
3737 """
3838 This function is an alias for the `sieve` function, offering a more
3939 descriptive name.
@@ -54,7 +54,7 @@ def remove_symbols(dirty): # type: (str) -> str
5454 return sieve (dirty )
5555
5656
57- def display (cnpj ): # type: ( str) -> str
57+ def display (cnpj : str ) -> str | None :
5858 """
5959 Will format an adequately formatted numbers-only CNPJ string,
6060 adding in standard formatting visual aid symbols for display.
@@ -90,7 +90,7 @@ def display(cnpj): # type: (str) -> str
9090 )
9191
9292
93- def format_cnpj (cnpj ): # type: ( str) -> str
93+ def format_cnpj (cnpj : str ) -> str | None :
9494 """
9595 Formats a CNPJ (Brazilian Company Registration Number) string for visual
9696 display.
@@ -124,7 +124,7 @@ def format_cnpj(cnpj): # type: (str) -> str
124124############
125125
126126
127- def validate (cnpj ): # type: ( str) -> bool
127+ def validate (cnpj : str ) -> bool :
128128 """
129129 Validates a CNPJ (Brazilian Company Registration Number) by comparing its
130130 verifying checksum digits to its base number.
@@ -158,7 +158,7 @@ def validate(cnpj): # type: (str) -> bool
158158 )
159159
160160
161- def is_valid (cnpj ): # type: ( str) -> bool
161+ def is_valid (cnpj : str ) -> bool :
162162 """
163163 Returns whether or not the verifying checksum digits of the given `cnpj`
164164 match its base number.
@@ -183,7 +183,7 @@ def is_valid(cnpj): # type: (str) -> bool
183183 return isinstance (cnpj , str ) and validate (cnpj )
184184
185185
186- def generate (branch = 1 ): # type: (int ) -> str
186+ def generate (branch : int = 1 ) -> str :
187187 """
188188 Generates a random valid CNPJ digit string. An optional branch number
189189 parameter can be given; it defaults to 1.
@@ -209,7 +209,7 @@ def generate(branch=1): # type: (int) -> str
209209 return base + _checksum (base )
210210
211211
212- def _hashdigit (cnpj , position ): # type: ( str, int) -> int
212+ def _hashdigit (cnpj : str , position : int ) -> int :
213213 """
214214 Calculates the checksum digit at the given `position` for the provided
215215 `cnpj`. The input must contain all elements before `position`.
@@ -235,7 +235,7 @@ def _hashdigit(cnpj, position): # type: (str, int) -> int
235235 return 0 if val < 2 else 11 - val
236236
237237
238- def _checksum (basenum ): # type: ( str) -> str
238+ def _checksum (basenum : str ) -> str :
239239 """
240240 Calculates the verifying checksum digits for a given CNPJ base number.
241241
0 commit comments