Skip to content

Commit c9dce80

Browse files
authored
chore: Bump pylint to v3.3.7 and astroid to v3.3.10 (#895)
* chore: Bump pylint to v3 * chore: fix src lint * chore: fix unit test lint * chore: fix integration test lint * chore: fix snippets lint * chore: 2nd pass for errors * fix: corrected use of the `bad-functions` config * fix: add EoF newline
1 parent d8e2269 commit c9dce80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+648
-688
lines changed

.pylintrc

Lines changed: 40 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[MASTER]
1+
[MAIN]
22

33
# Specify a configuration file.
44
#rcfile=
@@ -20,7 +20,9 @@ persistent=no
2020

2121
# List of plugins (as comma separated values of python modules names) to load,
2222
# usually to register additional checkers.
23-
load-plugins=pylint.extensions.docparams,pylint.extensions.docstyle
23+
load-plugins=pylint.extensions.docparams,
24+
pylint.extensions.docstyle,
25+
pylint.extensions.bad_builtin,
2426

2527
# Use multiple processes to speed up Pylint.
2628
jobs=1
@@ -34,15 +36,6 @@ unsafe-load-any-extension=no
3436
# run arbitrary code
3537
extension-pkg-whitelist=
3638

37-
# Allow optimization of some AST trees. This will activate a peephole AST
38-
# optimizer, which will apply various small optimizations. For instance, it can
39-
# be used to obtain the result of joining multiple strings with the addition
40-
# operator. Joining a lot of strings can lead to a maximum recursion error in
41-
# Pylint and this flag can prevent that. It has one side effect, the resulting
42-
# AST will be different than the one from reality. This option is deprecated
43-
# and it will be removed in Pylint 2.0.
44-
optimize-ast=no
45-
4639

4740
[MESSAGES CONTROL]
4841

@@ -65,21 +58,31 @@ enable=indexing-exception,old-raise-syntax
6558
# --enable=similarities". If you want to run only the classes checker, but have
6659
# no Warning level messages displayed, use"--disable=all --enable=classes
6760
# --disable=W"
68-
disable=design,similarities,no-self-use,attribute-defined-outside-init,locally-disabled,star-args,pointless-except,bad-option-value,global-statement,fixme,suppressed-message,useless-suppression,locally-enabled,file-ignored,missing-type-doc
61+
disable=design,
62+
similarities,
63+
no-self-use,
64+
attribute-defined-outside-init,
65+
locally-disabled,
66+
star-args,
67+
pointless-except,
68+
bad-option-value,
69+
lobal-statement,
70+
fixme,
71+
suppressed-message,
72+
useless-suppression,
73+
locally-enabled,
74+
file-ignored,
75+
missing-type-doc,
76+
c-extension-no-member,
6977

7078

7179
[REPORTS]
7280

73-
# Set the output format. Available formats are text, parseable, colorized, msvs
74-
# (visual studio) and html. You can also give a reporter class, eg
75-
# mypackage.mymodule.MyReporterClass.
76-
output-format=text
77-
78-
# Put messages in a separate file for each module / package specified on the
79-
# command line instead of printing them on stdout. Reports (if any) will be
80-
# written in a file name "pylint_global.[txt|html]". This option is deprecated
81-
# and it will be removed in Pylint 2.0.
82-
files-output=no
81+
# Set the output format. Available formats are: 'text', 'parseable',
82+
# 'colorized', 'json2' (improved json format), 'json' (old json format), msvs
83+
# (visual studio) and 'github' (GitHub actions). You can also give a reporter
84+
# class, e.g. mypackage.mymodule.MyReporterClass.
85+
output-format=colorized
8386

8487
# Tells whether to display a full report or only the messages
8588
reports=no
@@ -176,9 +179,12 @@ logging-modules=logging
176179
good-names=main,_
177180

178181
# Bad variable names which should always be refused, separated by a comma
179-
bad-names=
180-
181-
bad-functions=input,apply,reduce
182+
bad-names=foo,
183+
bar,
184+
baz,
185+
toto,
186+
tutu,
187+
tata
182188

183189
# Colon-delimited sets of names that determine each other's naming style when
184190
# the name regexes allow several styles.
@@ -194,64 +200,33 @@ property-classes=abc.abstractproperty
194200
# Regular expression matching correct function names
195201
function-rgx=[a-z_][a-z0-9_]*$
196202

197-
# Naming hint for function names
198-
function-name-hint=[a-z_][a-z0-9_]*$
199-
200203
# Regular expression matching correct variable names
201204
variable-rgx=[a-z_][a-z0-9_]{2,30}$
202205

203-
# Naming hint for variable names
204-
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
205-
206206
# Regular expression matching correct constant names
207207
const-rgx=^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
208208

209-
210-
# Naming hint for constant names
211-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
212-
213209
# Regular expression matching correct attribute names
214210
attr-rgx=[a-z_][a-z0-9_]{2,30}$
215211

216-
# Naming hint for attribute names
217-
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
218-
219212
# Regular expression matching correct argument names
220213
argument-rgx=[a-z_][a-z0-9_]{2,30}$
221214

222-
# Naming hint for argument names
223-
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
224-
225215
# Regular expression matching correct class attribute names
226216
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
227217

228-
# Naming hint for class attribute names
229-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
230-
231218
# Regular expression matching correct inline iteration names
232219
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
233220

234-
# Naming hint for inline iteration names
235-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
236-
237221
# Regular expression matching correct class names
238222
class-rgx=[A-Z_][a-zA-Z0-9]+$
239223

240-
# Naming hint for class names
241-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
242-
243224
# Regular expression matching correct module names
244225
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
245226

246-
# Naming hint for module names
247-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
248-
249227
# Regular expression matching correct method names
250228
method-rgx=[a-z_][a-z0-9_]*$
251229

252-
# Naming hint for method names
253-
method-name-hint=[a-z_][a-z0-9_]*$
254-
255230
# Regular expression which should only match function or class names that do
256231
# not require a docstring.
257232
no-docstring-rgx=(__.*__|main)
@@ -294,12 +269,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
294269
# else.
295270
single-line-if-stmt=no
296271

297-
# List of optional constructs for which whitespace checking is disabled. `dict-
298-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
299-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
300-
# `empty-line` allows space-only lines.
301-
no-space-check=trailing-comma,dict-separator
302-
303272
# Maximum number of lines in a module
304273
max-module-lines=1000
305274

@@ -405,6 +374,12 @@ exclude-protected=_asdict,_fields,_replace,_source,_make
405374

406375
[EXCEPTIONS]
407376

408-
# Exceptions that will emit a warning when being caught. Defaults to
409-
# "Exception"
410-
overgeneral-exceptions=Exception
377+
# Exceptions that will emit a warning when caught.
378+
overgeneral-exceptions=builtins.BaseException,builtins.Exception
379+
380+
[DEPRECATED_BUILTINS]
381+
382+
# List of builtins function names that should not be used, separated by a comma
383+
bad-functions=input,
384+
apply,
385+
reduce

firebase_admin/__init__.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def initialize_app(credential=None, options=None, name=_DEFAULT_APP_NAME):
7979
'apps, pass a second argument to initialize_app() to give each app '
8080
'a unique name.'))
8181

82-
raise ValueError((
83-
'Firebase app named "{0}" already exists. This means you called '
82+
raise ValueError(
83+
f'Firebase app named "{name}" already exists. This means you called '
8484
'initialize_app() more than once with the same app name as the '
8585
'second argument. Make sure you provide a unique name every time '
86-
'you call initialize_app().').format(name))
86+
'you call initialize_app().')
8787

8888

8989
def delete_app(app):
@@ -96,8 +96,7 @@ def delete_app(app):
9696
ValueError: If the app is not initialized.
9797
"""
9898
if not isinstance(app, App):
99-
raise ValueError('Illegal app argument type: "{}". Argument must be of '
100-
'type App.'.format(type(app)))
99+
raise ValueError(f'Illegal app argument type: "{type(app)}". Argument must be of type App.')
101100
with _apps_lock:
102101
if _apps.get(app.name) is app:
103102
del _apps[app.name]
@@ -109,9 +108,9 @@ def delete_app(app):
109108
'the default app by calling initialize_app().')
110109

111110
raise ValueError(
112-
('Firebase app named "{0}" is not initialized. Make sure to initialize '
113-
'the app by calling initialize_app() with your app name as the '
114-
'second argument.').format(app.name))
111+
f'Firebase app named "{app.name}" is not initialized. Make sure to initialize '
112+
'the app by calling initialize_app() with your app name as the '
113+
'second argument.')
115114

116115

117116
def get_app(name=_DEFAULT_APP_NAME):
@@ -128,8 +127,8 @@ def get_app(name=_DEFAULT_APP_NAME):
128127
app does not exist.
129128
"""
130129
if not isinstance(name, str):
131-
raise ValueError('Illegal app name argument type: "{}". App name '
132-
'must be a string.'.format(type(name)))
130+
raise ValueError(
131+
f'Illegal app name argument type: "{type(name)}". App name must be a string.')
133132
with _apps_lock:
134133
if name in _apps:
135134
return _apps[name]
@@ -140,9 +139,9 @@ def get_app(name=_DEFAULT_APP_NAME):
140139
'the SDK by calling initialize_app().')
141140

142141
raise ValueError(
143-
('Firebase app named "{0}" does not exist. Make sure to initialize '
144-
'the SDK by calling initialize_app() with your app name as the '
145-
'second argument.').format(name))
142+
f'Firebase app named "{name}" does not exist. Make sure to initialize '
143+
'the SDK by calling initialize_app() with your app name as the '
144+
'second argument.')
146145

147146

148147
class _AppOptions:
@@ -153,8 +152,9 @@ def __init__(self, options):
153152
options = self._load_from_environment()
154153

155154
if not isinstance(options, dict):
156-
raise ValueError('Illegal Firebase app options type: {0}. Options '
157-
'must be a dictionary.'.format(type(options)))
155+
raise ValueError(
156+
f'Illegal Firebase app options type: {type(options)}. '
157+
'Options must be a dictionary.')
158158
self._options = options
159159

160160
def get(self, key, default=None):
@@ -175,15 +175,15 @@ def _load_from_environment(self):
175175
json_str = config_file
176176
else:
177177
try:
178-
with open(config_file, 'r') as json_file:
178+
with open(config_file, 'r', encoding='utf-8') as json_file:
179179
json_str = json_file.read()
180180
except Exception as err:
181-
raise ValueError('Unable to read file {}. {}'.format(config_file, err)) from err
181+
raise ValueError(f'Unable to read file {config_file}. {err}') from err
182182
try:
183183
json_data = json.loads(json_str)
184184
except Exception as err:
185185
raise ValueError(
186-
'JSON string "{0}" is not valid json. {1}'.format(json_str, err)) from err
186+
f'JSON string "{json_str}" is not valid json. {err}') from err
187187
return {k: v for k, v in json_data.items() if k in _CONFIG_VALID_KEYS}
188188

189189

@@ -206,8 +206,9 @@ def __init__(self, name, credential, options):
206206
ValueError: If an argument is None or invalid.
207207
"""
208208
if not name or not isinstance(name, str):
209-
raise ValueError('Illegal Firebase app name "{0}" provided. App name must be a '
210-
'non-empty string.'.format(name))
209+
raise ValueError(
210+
f'Illegal Firebase app name "{name}" provided. App name must be a '
211+
'non-empty string.')
211212
self._name = name
212213

213214
if isinstance(credential, GoogleAuthCredentials):
@@ -228,7 +229,7 @@ def __init__(self, name, credential, options):
228229
def _validate_project_id(cls, project_id):
229230
if project_id is not None and not isinstance(project_id, str):
230231
raise ValueError(
231-
'Invalid project ID: "{0}". project ID must be a string.'.format(project_id))
232+
f'Invalid project ID: "{project_id}". project ID must be a string.')
232233

233234
@property
234235
def name(self):
@@ -293,11 +294,11 @@ def _get_service(self, name, initializer):
293294
"""
294295
if not name or not isinstance(name, str):
295296
raise ValueError(
296-
'Illegal name argument: "{0}". Name must be a non-empty string.'.format(name))
297+
f'Illegal name argument: "{name}". Name must be a non-empty string.')
297298
with self._lock:
298299
if self._services is None:
299300
raise ValueError(
300-
'Service requested from deleted Firebase App: "{0}".'.format(self._name))
301+
f'Service requested from deleted Firebase App: "{self._name}".')
301302
if name not in self._services:
302303
self._services[name] = initializer(self)
303304
return self._services[name]

firebase_admin/_auth_client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, app, tenant_id=None):
3838
3. set the project ID via the GOOGLE_CLOUD_PROJECT environment variable.""")
3939

4040
credential = None
41-
version_header = 'Python/Admin/{0}'.format(firebase_admin.__version__)
41+
version_header = f'Python/Admin/{firebase_admin.__version__}'
4242
timeout = app.options.get('httpTimeout', _http_client.DEFAULT_TIMEOUT_SECONDS)
4343
# Non-default endpoint URLs for emulator support are set in this dict later.
4444
endpoint_urls = {}
@@ -48,7 +48,7 @@ def __init__(self, app, tenant_id=None):
4848
# endpoint URLs to use the emulator. Additionally, use a fake credential.
4949
emulator_host = _auth_utils.get_emulator_host()
5050
if emulator_host:
51-
base_url = 'http://{0}/identitytoolkit.googleapis.com'.format(emulator_host)
51+
base_url = f'http://{emulator_host}/identitytoolkit.googleapis.com'
5252
endpoint_urls['v1'] = base_url + '/v1'
5353
endpoint_urls['v2'] = base_url + '/v2'
5454
credential = _utils.EmulatorAdminCredentials()
@@ -123,15 +123,16 @@ def verify_id_token(self, id_token, check_revoked=False, clock_skew_seconds=0):
123123
"""
124124
if not isinstance(check_revoked, bool):
125125
# guard against accidental wrong assignment.
126-
raise ValueError('Illegal check_revoked argument. Argument must be of type '
127-
' bool, but given "{0}".'.format(type(check_revoked)))
126+
raise ValueError(
127+
'Illegal check_revoked argument. Argument must be of type bool, but given '
128+
f'"{type(check_revoked)}".')
128129

129130
verified_claims = self._token_verifier.verify_id_token(id_token, clock_skew_seconds)
130131
if self.tenant_id:
131132
token_tenant_id = verified_claims.get('firebase', {}).get('tenant')
132133
if self.tenant_id != token_tenant_id:
133134
raise _auth_utils.TenantIdMismatchError(
134-
'Invalid tenant ID: {0}'.format(token_tenant_id))
135+
f'Invalid tenant ID: {token_tenant_id}')
135136

136137
if check_revoked:
137138
self._check_jwt_revoked_or_disabled(
@@ -249,7 +250,7 @@ def _matches(identifier, user_record):
249250
if identifier.provider_id == user_info.provider_id
250251
and identifier.provider_uid == user_info.uid
251252
), False)
252-
raise TypeError("Unexpected type: {}".format(type(identifier)))
253+
raise TypeError(f"Unexpected type: {type(identifier)}")
253254

254255
def _is_user_found(identifier, user_records):
255256
return any(_matches(identifier, user_record) for user_record in user_records)
@@ -757,4 +758,4 @@ def _check_jwt_revoked_or_disabled(self, verified_claims, exc_type, label):
757758
if user.disabled:
758759
raise _auth_utils.UserDisabledError('The user record is disabled.')
759760
if verified_claims.get('iat') * 1000 < user.tokens_valid_after_timestamp:
760-
raise exc_type('The Firebase {0} has been revoked.'.format(label))
761+
raise exc_type(f'The Firebase {label} has been revoked.')

0 commit comments

Comments
 (0)