11import re
22from typing import Union
33
4- from inifix ._deprecation import future_positional_only
54
65ENOTATION_REGEXP = re .compile (r"\d+(\.\d*)?e[+-]?\d+?" )
76
@@ -13,8 +12,7 @@ class ENotationIO:
1312 """
1413
1514 @staticmethod
16- @future_positional_only ({0 : "s" })
17- def decode (s : str ) -> int :
15+ def decode (s : str , / ) -> int :
1816 """
1917 Cast an 'e' formatted string `s` to integer if such a conversion can
2018 be perfomed without loss of data. Raise ValueError otherwise.
@@ -52,8 +50,8 @@ def decode(s: str) -> int:
5250 if not re .match (ENOTATION_REGEXP , s ):
5351 raise ValueError
5452
55- digits , _ , exponent = s .partition ("e" )
56- exponent = int (exponent )
53+ digits , _ , sexponent = s .partition ("e" )
54+ exponent = int (sexponent )
5755 if "." in digits :
5856 digits , decimals = digits .split ("." )
5957 decimals = decimals .rstrip ("0" )
@@ -68,8 +66,7 @@ def decode(s: str) -> int:
6866 return int (float (s ))
6967
7068 @staticmethod
71- @future_positional_only ({0 : "s" })
72- def simplify (s : str ) -> str :
69+ def simplify (s : str , / ) -> str :
7370 """
7471 Simplify exponents and trailing zeros in decimals.
7572 This is a helper function to `ENotationIO.encode`.
@@ -94,8 +91,7 @@ def simplify(s: str) -> str:
9491 return s .replace ("+" , "" )
9592
9693 @staticmethod
97- @future_positional_only ({0 : "r" })
98- def encode (r : Union [float , int ]) -> str :
94+ def encode (r : Union [float , int ], / ) -> str :
9995 """
10096 Convert a real number `r` to string, using scientific notation.
10197
@@ -144,8 +140,7 @@ def encode(r: Union[float, int]) -> str:
144140 return ENotationIO .simplify (s )
145141
146142 @staticmethod
147- @future_positional_only ({0 : "r" })
148- def encode_preferential (r : Union [float , int ]) -> str :
143+ def encode_preferential (r : Union [float , int ], / ) -> str :
149144 """
150145 Convert a real number `r` to string, using sci notation if
151146 and only if it saves space.
0 commit comments