Skip to content

Commit cc86db2

Browse files
committed
- remove redundant overriding methods
- fix some pylint issues
1 parent d6807f5 commit cc86db2

File tree

6 files changed

+19
-124
lines changed

6 files changed

+19
-124
lines changed

firebase_admin/_auth_utils.py

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@
2424
Literal,
2525
Optional,
2626
Protocol,
27-
Union,
2827
cast,
2928
overload,
3029
)
3130
from urllib import parse
3231

33-
import httpx
3432
import requests
3533
from typing_extensions import Self, TypeVar
3634

@@ -476,28 +474,12 @@ class UidAlreadyExistsError(exceptions.AlreadyExistsError):
476474

477475
default_message = 'The user with the provided uid already exists'
478476

479-
def __init__(
480-
self,
481-
message: str,
482-
cause: Optional[Exception],
483-
http_response: Optional[Union[httpx.Response, requests.Response]],
484-
) -> None:
485-
super().__init__(message, cause, http_response)
486-
487477

488478
class EmailAlreadyExistsError(exceptions.AlreadyExistsError):
489479
"""The user with the provided email already exists."""
490480

491481
default_message = 'The user with the provided email already exists'
492482

493-
def __init__(
494-
self,
495-
message: str,
496-
cause: Optional[Exception],
497-
http_response: Optional[Union[httpx.Response, requests.Response]],
498-
) -> None:
499-
super().__init__(message, cause, http_response)
500-
501483

502484
class InsufficientPermissionError(exceptions.PermissionDeniedError):
503485
"""The credential used to initialize the SDK lacks required permissions."""
@@ -507,169 +489,70 @@ class InsufficientPermissionError(exceptions.PermissionDeniedError):
507489
'https://firebase.google.com/docs/admin/setup for details '
508490
'on how to initialize the Admin SDK with appropriate permissions')
509491

510-
def __init__(
511-
self,
512-
message: str,
513-
cause: Optional[Exception],
514-
http_response: Optional[Union[httpx.Response, requests.Response]],
515-
) -> None:
516-
super().__init__(message, cause, http_response)
517-
518492

519493
class InvalidDynamicLinkDomainError(exceptions.InvalidArgumentError):
520494
"""Dynamic link domain in ActionCodeSettings is not authorized."""
521495

522496
default_message = 'Dynamic link domain specified in ActionCodeSettings is not authorized'
523497

524-
def __init__(
525-
self,
526-
message: str,
527-
cause: Optional[Exception],
528-
http_response: Optional[Union[httpx.Response, requests.Response]],
529-
) -> None:
530-
super().__init__(message, cause, http_response)
531-
532498

533499
class InvalidIdTokenError(exceptions.InvalidArgumentError):
534500
"""The provided ID token is not a valid Firebase ID token."""
535501

536502
default_message = 'The provided ID token is invalid'
537503

538-
def __init__(
539-
self,
540-
message: str,
541-
cause: Optional[Exception] = None,
542-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
543-
) -> None:
544-
super().__init__(message, cause, http_response)
545-
546504

547505
class PhoneNumberAlreadyExistsError(exceptions.AlreadyExistsError):
548506
"""The user with the provided phone number already exists."""
549507

550508
default_message = 'The user with the provided phone number already exists'
551509

552-
def __init__(
553-
self,
554-
message: str,
555-
cause: Optional[Exception],
556-
http_response: Optional[Union[httpx.Response, requests.Response]],
557-
) -> None:
558-
super().__init__(message, cause, http_response)
559-
560510

561511
class UnexpectedResponseError(exceptions.UnknownError):
562512
"""Backend service responded with an unexpected or malformed response."""
563513

564-
def __init__(
565-
self,
566-
message: str,
567-
cause: Optional[Exception] = None,
568-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
569-
) -> None:
570-
super().__init__(message, cause, http_response)
571-
572514

573515
class UserNotFoundError(exceptions.NotFoundError):
574516
"""No user record found for the specified identifier."""
575517

576518
default_message = 'No user record found for the given identifier'
577519

578-
def __init__(
579-
self,
580-
message: str,
581-
cause: Optional[Exception] = None,
582-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
583-
) -> None:
584-
super().__init__(message, cause, http_response)
585-
586520

587521
class EmailNotFoundError(exceptions.NotFoundError):
588522
"""No user record found for the specified email."""
589523

590524
default_message = 'No user record found for the given email'
591525

592-
def __init__(
593-
self,
594-
message: str,
595-
cause: Optional[Exception] = None,
596-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
597-
) -> None:
598-
super().__init__(message, cause, http_response)
599-
600526

601527
class TenantNotFoundError(exceptions.NotFoundError):
602528
"""No tenant found for the specified identifier."""
603529

604530
default_message = 'No tenant found for the given identifier'
605531

606-
def __init__(
607-
self,
608-
message: str,
609-
cause: Optional[Exception] = None,
610-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
611-
) -> None:
612-
super().__init__(message, cause, http_response)
613-
614532

615533
class TenantIdMismatchError(exceptions.InvalidArgumentError):
616534
"""Missing or invalid tenant ID field in the given JWT."""
617535

618-
def __init__(self, message: str) -> None:
619-
super().__init__(message)
620-
621536

622537
class ConfigurationNotFoundError(exceptions.NotFoundError):
623538
"""No auth provider found for the specified identifier."""
624539

625540
default_message = 'No auth provider found for the given identifier'
626541

627-
def __init__(
628-
self,
629-
message: str,
630-
cause: Optional[Exception] = None,
631-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
632-
) -> None:
633-
super().__init__(message, cause, http_response)
634-
635542

636543
class UserDisabledError(exceptions.InvalidArgumentError):
637544
"""An operation failed due to a user record being disabled."""
638545

639546
default_message = 'The user record is disabled'
640547

641-
def __init__(
642-
self,
643-
message: str,
644-
cause: Optional[Exception] = None,
645-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
646-
) -> None:
647-
super().__init__(message, cause, http_response)
648-
649548

650549
class TooManyAttemptsTryLaterError(exceptions.ResourceExhaustedError):
651550
"""Rate limited because of too many attempts."""
652551

653-
def __init__(
654-
self,
655-
message: str,
656-
cause: Optional[Exception] = None,
657-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
658-
) -> None:
659-
super().__init__(message, cause, http_response)
660-
661552

662553
class ResetPasswordExceedLimitError(exceptions.ResourceExhaustedError):
663554
"""Reset password emails exceeded their limits."""
664555

665-
def __init__(
666-
self,
667-
message: str,
668-
cause: Optional[Exception] = None,
669-
http_response: Optional[Union[httpx.Response, requests.Response]] = None,
670-
) -> None:
671-
super().__init__(message, cause, http_response)
672-
673556

674557
_CODE_TO_EXC_TYPE = {
675558
'CONFIGURATION_NOT_FOUND': ConfigurationNotFoundError,

firebase_admin/_sseclient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __next__(self) -> Optional['Event']:
163163
return event
164164

165165
def next(self) -> Optional['Event']:
166-
return self.__next__()
166+
return next(self)
167167

168168

169169
class Event:

firebase_admin/db.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636
cast,
3737
overload,
3838
)
39-
from typing_extensions import Self, TypeVar
4039
from urllib import parse
4140

4241
import google.auth.credentials
4342
import requests
43+
from typing_extensions import Self, TypeVar
44+
4445

4546
import firebase_admin
4647
from firebase_admin import exceptions
@@ -849,7 +850,10 @@ def __gt__(self, other: '_SortEntry') -> bool:
849850
def __ge__(self, other: '_SortEntry') -> bool:
850851
return self._compare(other) >= 0
851852

852-
def __eq__(self, other: '_SortEntry') -> bool: # pyright: ignore[reportIncompatibleMethodOverride]
853+
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride]
854+
self,
855+
other: '_SortEntry',
856+
) -> bool:
853857
return self._compare(other) == 0
854858

855859

firebase_admin/ml.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ def _convert_to_millis(date_string: Optional[str]) -> Optional[int]:
290290
return None
291291
format_str = '%Y-%m-%dT%H:%M:%S.%fZ'
292292
epoch = datetime.datetime.fromtimestamp(0, datetime.timezone.utc)
293-
datetime_object = datetime.datetime.strptime(date_string, format_str).replace(tzinfo=datetime.timezone.utc)
293+
datetime_object = datetime.datetime.strptime(
294+
date_string, format_str).replace(tzinfo=datetime.timezone.utc)
294295
millis = int((datetime_object - epoch).total_seconds() * 1000)
295296
return millis
296297

@@ -881,7 +882,11 @@ def get_operation(self, op_name: str) -> dict[str, Any]:
881882
except requests.exceptions.RequestException as error:
882883
raise _utils.handle_platform_error_from_requests(error)
883884

884-
def _exponential_backoff(self, current_attempt: int, stop_time: Optional[datetime.datetime]) -> None:
885+
def _exponential_backoff(
886+
self,
887+
current_attempt: int,
888+
stop_time: Optional[datetime.datetime],
889+
) -> None:
885890
"""Sleeps for the appropriate amount of time. Or throws deadline exceeded."""
886891
delay_factor = pow(_MLService.POLL_EXPONENTIAL_BACKOFF_FACTOR, current_attempt)
887892
wait_time_seconds = delay_factor * _MLService.POLL_BASE_WAIT_TIME_SECONDS

firebase_admin/remote_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,10 @@ def _get_url(self) -> str:
302302
return f"/v1/projects/{self._project_id}/namespaces/firebase-server/serverRemoteConfig"
303303

304304
@classmethod
305-
def _handle_remote_config_error(cls, error: requests.RequestException) -> exceptions.FirebaseError:
305+
def _handle_remote_config_error(
306+
cls,
307+
error: requests.RequestException,
308+
) -> exceptions.FirebaseError:
306309
"""Handles errors received from the Cloud Functions API."""
307310
return _utils.handle_platform_error_from_requests(error)
308311

firebase_admin/tenant_mgt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def delete_tenant(self, tenant_id: str) -> None:
340340
"""Deletes the tenant corresponding to the given ``tenant_id``."""
341341
if not isinstance(tenant_id, str) or not tenant_id:
342342
raise ValueError(
343-
'Invalid tenant ID: {0}. Tenant ID must be a non-empty string.'.format(tenant_id))
343+
f'Invalid tenant ID: {tenant_id}. Tenant ID must be a non-empty string.')
344344

345345
try:
346346
self.client.request('delete', f'/tenants/{tenant_id}')

0 commit comments

Comments
 (0)