Skip to content

Commit 3d95449

Browse files
authored
🐛 fix single quote issue (#148)
* 🐛 fix single quote issue * ♻️ fix all single quotes issue
1 parent 303bb8d commit 3d95449

27 files changed

+935
-917
lines changed

pydantic_extra_types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.5.0"
1+
__version__ = '2.5.0'

pydantic_extra_types/color.py

Lines changed: 193 additions & 193 deletions
Large diffs are not rendered by default.

pydantic_extra_types/coordinate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ def _parse_str(cls, value: Any, handler: core_schema.ValidatorFunctionWrapHandle
121121
if not isinstance(value, str):
122122
return value
123123
try:
124-
value = tuple(float(x) for x in value.split(","))
124+
value = tuple(float(x) for x in value.split(','))
125125
except ValueError:
126126
raise PydanticCustomError(
127-
"coordinate_error",
128-
"value is not a valid coordinate: string is not recognized as a valid coordinate",
127+
'coordinate_error',
128+
'value is not a valid coordinate: string is not recognized as a valid coordinate',
129129
)
130130
return ArgsKwargs(args=value)
131131

@@ -136,7 +136,7 @@ def _parse_tuple(cls, value: Any, handler: core_schema.ValidatorFunctionWrapHand
136136
return ArgsKwargs(args=handler(value))
137137

138138
def __str__(self) -> str:
139-
return f"{self.latitude},{self.longitude}"
139+
return f'{self.latitude},{self.longitude}'
140140

141141
def __eq__(self, other: Any) -> bool:
142142
return isinstance(other, Coordinate) and self.latitude == other.latitude and self.longitude == other.longitude

pydantic_extra_types/country.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Product(BaseModel):
8080
@classmethod
8181
def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> CountryAlpha2:
8282
if __input_value not in _index_by_alpha2():
83-
raise PydanticCustomError("country_alpha2", "Invalid country alpha2 code")
83+
raise PydanticCustomError('country_alpha2', 'Invalid country alpha2 code')
8484
return cls(__input_value)
8585

8686
@classmethod
@@ -97,7 +97,7 @@ def __get_pydantic_json_schema__(
9797
cls, schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
9898
) -> dict[str, Any]:
9999
json_schema = handler(schema)
100-
json_schema.update({"pattern": r"^\w{2}$"})
100+
json_schema.update({'pattern': r'^\w{2}$'})
101101
return json_schema
102102

103103
@property
@@ -137,7 +137,7 @@ class Product(BaseModel):
137137
@classmethod
138138
def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> CountryAlpha3:
139139
if __input_value not in _index_by_alpha3():
140-
raise PydanticCustomError("country_alpha3", "Invalid country alpha3 code")
140+
raise PydanticCustomError('country_alpha3', 'Invalid country alpha3 code')
141141
return cls(__input_value)
142142

143143
@classmethod
@@ -155,7 +155,7 @@ def __get_pydantic_json_schema__(
155155
cls, schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
156156
) -> dict[str, Any]:
157157
json_schema = handler(schema)
158-
json_schema.update({"pattern": r"^\w{3}$"})
158+
json_schema.update({'pattern': r'^\w{3}$'})
159159
return json_schema
160160

161161
@property
@@ -195,7 +195,7 @@ class Product(BaseModel):
195195
@classmethod
196196
def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> CountryNumericCode:
197197
if __input_value not in _index_by_numeric_code():
198-
raise PydanticCustomError("country_numeric_code", "Invalid country numeric code")
198+
raise PydanticCustomError('country_numeric_code', 'Invalid country numeric code')
199199
return cls(__input_value)
200200

201201
@classmethod
@@ -213,7 +213,7 @@ def __get_pydantic_json_schema__(
213213
cls, schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
214214
) -> dict[str, Any]:
215215
json_schema = handler(schema)
216-
json_schema.update({"pattern": r"^[0-9]{3}$"})
216+
json_schema.update({'pattern': r'^[0-9]{3}$'})
217217
return json_schema
218218

219219
@property
@@ -252,7 +252,7 @@ class Product(BaseModel):
252252
@classmethod
253253
def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> CountryShortName:
254254
if __input_value not in _index_by_short_name():
255-
raise PydanticCustomError("country_short_name", "Invalid country short name")
255+
raise PydanticCustomError('country_short_name', 'Invalid country short name')
256256
return cls(__input_value)
257257

258258
@classmethod

pydantic_extra_types/currency_code.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818

1919
# List of codes that should not be usually used within regular transactions
2020
_CODES_FOR_BONDS_METAL_TESTING = {
21-
"XTS", # testing
22-
"XAU", # gold
23-
"XAG", # silver
24-
"XPD", # palladium
25-
"XPT", # platinum
26-
"XBA", # Bond Markets Unit European Composite Unit (EURCO)
27-
"XBB", # Bond Markets Unit European Monetary Unit (E.M.U.-6)
28-
"XBC", # Bond Markets Unit European Unit of Account 9 (E.U.A.-9)
29-
"XBD", # Bond Markets Unit European Unit of Account 17 (E.U.A.-17)
30-
"XXX", # no currency
31-
"XDR", # SDR (Special Drawing Right)
21+
'XTS', # testing
22+
'XAU', # gold
23+
'XAG', # silver
24+
'XPD', # palladium
25+
'XPT', # platinum
26+
'XBA', # Bond Markets Unit European Composite Unit (EURCO)
27+
'XBB', # Bond Markets Unit European Monetary Unit (E.M.U.-6)
28+
'XBC', # Bond Markets Unit European Unit of Account 9 (E.U.A.-9)
29+
'XBD', # Bond Markets Unit European Unit of Account 17 (E.U.A.-17)
30+
'XXX', # no currency
31+
'XDR', # SDR (Special Drawing Right)
3232
}
3333

3434

@@ -69,7 +69,7 @@ def _validate(cls, currency_code: str, _: core_schema.ValidationInfo) -> str:
6969
"""
7070
if currency_code not in cls.allowed_currencies:
7171
raise PydanticCustomError(
72-
"ISO4217", "Invalid ISO 4217 currency code. See https://en.wikipedia.org/wiki/ISO_4217"
72+
'ISO4217', 'Invalid ISO 4217 currency code. See https://en.wikipedia.org/wiki/ISO_4217'
7373
)
7474
return currency_code
7575

@@ -85,7 +85,7 @@ def __get_pydantic_json_schema__(
8585
cls, schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler
8686
) -> dict[str, Any]:
8787
json_schema = handler(schema)
88-
json_schema.update({"enum": cls.allowed_countries_list})
88+
json_schema.update({'enum': cls.allowed_countries_list})
8989
return json_schema
9090

9191

@@ -129,10 +129,10 @@ def _validate(cls, currency_symbol: str, _: core_schema.ValidationInfo) -> str:
129129
"""
130130
if currency_symbol not in cls.allowed_currencies:
131131
raise PydanticCustomError(
132-
"InvalidCurrency",
133-
"Invalid currency code."
134-
" See https://en.wikipedia.org/wiki/ISO_4217. "
135-
"Bonds, testing and precious metals codes are not allowed.",
132+
'InvalidCurrency',
133+
'Invalid currency code.'
134+
' See https://en.wikipedia.org/wiki/ISO_4217. '
135+
'Bonds, testing and precious metals codes are not allowed.',
136136
)
137137
return currency_symbol
138138

@@ -175,5 +175,5 @@ def __get_pydantic_json_schema__(
175175
176176
"""
177177
json_schema = handler(schema)
178-
json_schema.update({"enum": cls.allowed_countries_list})
178+
json_schema.update({'enum': cls.allowed_countries_list})
179179
return json_schema

pydantic_extra_types/isbn.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def isbn10_digit_calc(isbn: str) -> str:
2525

2626
for check_digit in range(1, 11):
2727
if (total + check_digit) % 11 == 0:
28-
valid_check_digit = "X" if check_digit == 10 else str(check_digit)
28+
valid_check_digit = 'X' if check_digit == 10 else str(check_digit)
2929

3030
return valid_check_digit
3131

@@ -115,23 +115,23 @@ def validate_isbn_format(value: str) -> None:
115115
isbn_length = len(value)
116116

117117
if isbn_length not in (10, 13):
118-
raise PydanticCustomError("isbn_length", f"Length for ISBN must be 10 or 13 digits, not {isbn_length}")
118+
raise PydanticCustomError('isbn_length', f'Length for ISBN must be 10 or 13 digits, not {isbn_length}')
119119

120120
if isbn_length == 10:
121-
if not value[:-1].isdigit() or ((value[-1] != "X") and (not value[-1].isdigit())):
122-
raise PydanticCustomError("isbn10_invalid_characters", "First 9 digits of ISBN-10 must be integers")
121+
if not value[:-1].isdigit() or ((value[-1] != 'X') and (not value[-1].isdigit())):
122+
raise PydanticCustomError('isbn10_invalid_characters', 'First 9 digits of ISBN-10 must be integers')
123123
if isbn10_digit_calc(value) != value[-1]:
124-
raise PydanticCustomError("isbn_invalid_digit_check_isbn10", "Provided digit is invalid for given ISBN")
124+
raise PydanticCustomError('isbn_invalid_digit_check_isbn10', 'Provided digit is invalid for given ISBN')
125125

126126
if isbn_length == 13:
127127
if not value.isdigit():
128-
raise PydanticCustomError("isbn13_invalid_characters", "All digits of ISBN-13 must be integers")
129-
if value[:3] not in ("978", "979"):
128+
raise PydanticCustomError('isbn13_invalid_characters', 'All digits of ISBN-13 must be integers')
129+
if value[:3] not in ('978', '979'):
130130
raise PydanticCustomError(
131-
"isbn_invalid_early_characters", "The first 3 digits of ISBN-13 must be 978 or 979"
131+
'isbn_invalid_early_characters', 'The first 3 digits of ISBN-13 must be 978 or 979'
132132
)
133133
if isbn13_digit_calc(value) != value[-1]:
134-
raise PydanticCustomError("isbn_invalid_digit_check_isbn13", "Provided digit is invalid for given ISBN")
134+
raise PydanticCustomError('isbn_invalid_digit_check_isbn13', 'Provided digit is invalid for given ISBN')
135135

136136
@staticmethod
137137
def convert_isbn10_to_isbn13(value: str) -> str:
@@ -145,8 +145,8 @@ def convert_isbn10_to_isbn13(value: str) -> str:
145145
"""
146146

147147
if len(value) == 10:
148-
base_isbn = f"978{value[:-1]}"
148+
base_isbn = f'978{value[:-1]}'
149149
isbn13_digit = isbn13_digit_calc(base_isbn)
150-
return ISBN(f"{base_isbn}{isbn13_digit}")
150+
return ISBN(f'{base_isbn}{isbn13_digit}')
151151

152152
return ISBN(value)

pydantic_extra_types/language_code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> ISO639_
5555
"""
5656
if __input_value not in cls.allowed_values:
5757
raise PydanticCustomError(
58-
"ISO649_3", "Invalid ISO 639-3 language code. See https://en.wikipedia.org/wiki/ISO_639-3"
58+
'ISO649_3', 'Invalid ISO 639-3 language code. See https://en.wikipedia.org/wiki/ISO_639-3'
5959
)
6060
return cls(__input_value)
6161

@@ -95,7 +95,7 @@ def __get_pydantic_json_schema__(
9595
9696
"""
9797
json_schema = handler(schema)
98-
json_schema.update({"enum": cls.allowed_values_list})
98+
json_schema.update({'enum': cls.allowed_values_list})
9999
return json_schema
100100

101101

@@ -138,7 +138,7 @@ def _validate(cls, __input_value: str, _: core_schema.ValidationInfo) -> ISO639_
138138
"""
139139
if __input_value not in cls.allowed_values:
140140
raise PydanticCustomError(
141-
"ISO649_5", "Invalid ISO 639-5 language code. See https://en.wikipedia.org/wiki/ISO_639-5"
141+
'ISO649_5', 'Invalid ISO 639-5 language code. See https://en.wikipedia.org/wiki/ISO_639-5'
142142
)
143143
return cls(__input_value)
144144

@@ -178,5 +178,5 @@ def __get_pydantic_json_schema__(
178178
179179
"""
180180
json_schema = handler(schema)
181-
json_schema.update({"enum": cls.allowed_values_list})
181+
json_schema.update({'enum': cls.allowed_values_list})
182182
return json_schema

pydantic_extra_types/mac_address.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ def validate_mac_address(value: bytes) -> str:
7070
"""
7171
if len(value) < 14:
7272
raise PydanticCustomError(
73-
"mac_address_len",
74-
"Length for a {mac_address} MAC address must be {required_length}",
75-
{"mac_address": value.decode(), "required_length": 14},
73+
'mac_address_len',
74+
'Length for a {mac_address} MAC address must be {required_length}',
75+
{'mac_address': value.decode(), 'required_length': 14},
7676
)
7777

78-
if value[2] in [ord(":"), ord("-")]:
78+
if value[2] in [ord(':'), ord('-')]:
7979
if (len(value) + 1) % 3 != 0:
8080
raise PydanticCustomError(
81-
"mac_address_format", "Must have the format xx:xx:xx:xx:xx:xx or xx-xx-xx-xx-xx-xx"
81+
'mac_address_format', 'Must have the format xx:xx:xx:xx:xx:xx or xx-xx-xx-xx-xx-xx'
8282
)
8383
n = (len(value) + 1) // 3
8484
if n not in (6, 8, 20):
8585
raise PydanticCustomError(
86-
"mac_address_format",
87-
"Length for a {mac_address} MAC address must be {required_length}",
88-
{"mac_address": value.decode(), "required_length": (6, 8, 20)},
86+
'mac_address_format',
87+
'Length for a {mac_address} MAC address must be {required_length}',
88+
{'mac_address': value.decode(), 'required_length': (6, 8, 20)},
8989
)
9090
mac_address = bytearray(n)
9191
x = 0
@@ -95,17 +95,17 @@ def validate_mac_address(value: bytes) -> str:
9595
mac_address[i] = byte_value
9696
x += 3
9797
except ValueError as e:
98-
raise PydanticCustomError("mac_address_format", "Unrecognized format") from e
98+
raise PydanticCustomError('mac_address_format', 'Unrecognized format') from e
9999

100-
elif value[4] == ord("."):
100+
elif value[4] == ord('.'):
101101
if (len(value) + 1) % 5 != 0:
102-
raise PydanticCustomError("mac_address_format", "Must have the format xx.xx.xx.xx.xx.xx")
102+
raise PydanticCustomError('mac_address_format', 'Must have the format xx.xx.xx.xx.xx.xx')
103103
n = 2 * (len(value) + 1) // 5
104104
if n not in (6, 8, 20):
105105
raise PydanticCustomError(
106-
"mac_address_format",
107-
"Length for a {mac_address} MAC address must be {required_length}",
108-
{"mac_address": value.decode(), "required_length": (6, 8, 20)},
106+
'mac_address_format',
107+
'Length for a {mac_address} MAC address must be {required_length}',
108+
{'mac_address': value.decode(), 'required_length': (6, 8, 20)},
109109
)
110110
mac_address = bytearray(n)
111111
x = 0
@@ -117,9 +117,9 @@ def validate_mac_address(value: bytes) -> str:
117117
mac_address[i + 1] = byte_value
118118
x += 5
119119
except ValueError as e:
120-
raise PydanticCustomError("mac_address_format", "Unrecognized format") from e
120+
raise PydanticCustomError('mac_address_format', 'Unrecognized format') from e
121121

122122
else:
123-
raise PydanticCustomError("mac_address_format", "Unrecognized format")
123+
raise PydanticCustomError('mac_address_format', 'Unrecognized format')
124124

125-
return ":".join(f"{b:02x}" for b in mac_address)
125+
return ':'.join(f'{b:02x}' for b in mac_address)

0 commit comments

Comments
 (0)