Skip to content

Commit

Permalink
modernize typing across the board
Browse files Browse the repository at this point in the history
mostly stops typing self and __all__
also patch the linter and remove some unused imports a little while i'm touching everything
  • Loading branch information
ShineyDev committed Jan 25, 2025
1 parent 6be56ab commit c977697
Show file tree
Hide file tree
Showing 93 changed files with 787 additions and 887 deletions.
2 changes: 1 addition & 1 deletion github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _VersionInfo(NamedTuple):
version_info: _VersionInfo = _VersionInfo(1, 0, 0, 0, "alpha", 0)


__all__: list[str] = [ # type: ignore[reportUnsupportedDunderAll]
__all__ = [ # type: ignore[reportUnsupportedDunderAll]
*_core__all__,
*_interfaces__all__,
*_api__all__,
Expand Down
2 changes: 1 addition & 1 deletion github/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from github.api.ratelimit import __all__ as _ratelimit__all__


__all__: list[str] = [ # type: ignore[reportUnsupportedDunderAll]
__all__ = [ # type: ignore[reportUnsupportedDunderAll]
*_metadata__all__,
*_ratelimit__all__,
]
23 changes: 10 additions & 13 deletions github/api/metadata.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from __future__ import annotations
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing_extensions import Self

from github.interfaces import Type


Expand Down Expand Up @@ -43,10 +40,10 @@ def _patch_data(

@classmethod
def _from_data(
cls: type[Self],
cls,
data: MetadataData,
/,
) -> Self:
):
return cls(cls._patch_data(data))

_graphql_fields = {
Expand All @@ -63,7 +60,7 @@ def _from_data(

@property
def enterprise_importer_ip_addresses(
self: Self,
self,
/,
) -> list[str]:
"""
Expand All @@ -77,7 +74,7 @@ def enterprise_importer_ip_addresses(

@property
def git_ip_addresses(
self: Self,
self,
/,
) -> list[str]:
"""
Expand All @@ -90,7 +87,7 @@ def git_ip_addresses(

@property
def github_services_sha(
self: Self,
self,
/,
) -> str:
"""
Expand All @@ -103,7 +100,7 @@ def github_services_sha(

@property
def webhook_ip_addresses(
self: Self,
self,
/,
) -> list[str]:
"""
Expand All @@ -116,7 +113,7 @@ def webhook_ip_addresses(

@property
def importer_ip_addresses(
self: Self,
self,
/,
) -> list[str]:
"""
Expand All @@ -129,7 +126,7 @@ def importer_ip_addresses(

@property
def is_password_authentication_verifiable(
self: Self,
self,
/,
) -> bool:
"""
Expand All @@ -147,7 +144,7 @@ def is_password_authentication_verifiable(

@property
def pages_ip_addresses(
self: Self,
self,
/,
) -> list[str]:
"""
Expand All @@ -159,6 +156,6 @@ def pages_ip_addresses(
return self._data["pagesIpAddresses"]


__all__: list[str] = [
__all__ = [
"Metadata",
]
16 changes: 7 additions & 9 deletions github/api/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing_extensions import Self

from github.utility.types import DateTime

import github
Expand Down Expand Up @@ -46,10 +44,10 @@ def _patch_data(

@classmethod
def _from_data(
cls: type[Self],
cls,
data: RateLimitData,
/,
) -> Self:
):
return cls(cls._patch_data(data))

_graphql_fields = {
Expand All @@ -61,7 +59,7 @@ def _from_data(

@property
def limit(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -86,7 +84,7 @@ def limit(

@property
def remaining(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -111,7 +109,7 @@ def remaining(

@property
def resets_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -124,7 +122,7 @@ def resets_at(

@property
def used(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -147,6 +145,6 @@ def used(
return used


__all__: list[str] = [
__all__ = [
"RateLimit",
]
2 changes: 1 addition & 1 deletion github/automation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from github.automation.mannequin import __all__ as _mannequin__all__


__all__: list[str] = [ # type: ignore[reportUnsupportedDunderAll]
__all__ = [ # type: ignore[reportUnsupportedDunderAll]
*_bot__all__,
*_mannequin__all__,
]
17 changes: 8 additions & 9 deletions github/automation/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

if TYPE_CHECKING:
from typing import cast
from typing_extensions import Self

from github.core.http import HTTPClient
from github.utility.types import DateTime
Expand Down Expand Up @@ -59,12 +58,12 @@ def _patch_data(

@classmethod
def _from_data(
cls: type[Self],
cls,
data: BotData,
/,
*,
http: HTTPClient,
) -> Self:
):
return cls(cls._patch_data(data), http)

_graphql_fields = {
Expand All @@ -77,7 +76,7 @@ def _from_data(

@property
def created_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -90,7 +89,7 @@ def created_at(

@property
def database_id(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -103,7 +102,7 @@ def database_id(

@property
def updated_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -115,7 +114,7 @@ def updated_at(
return github.utility.iso_to_datetime(self._data["updatedAt"])

async def fetch_created_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -142,7 +141,7 @@ async def fetch_created_at(
return github.utility.iso_to_datetime(created_at)

async def fetch_database_id(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -164,7 +163,7 @@ async def fetch_database_id(
return await self._fetch_field("databaseId") # type: ignore

async def fetch_updated_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand Down
17 changes: 8 additions & 9 deletions github/automation/mannequin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

if TYPE_CHECKING:
from typing import cast
from typing_extensions import Self

from github.core.http import HTTPClient
from github.utility.types import DateTime
Expand Down Expand Up @@ -62,12 +61,12 @@ def _patch_data(

@classmethod
def _from_data(
cls: type[Self],
cls,
data: MannequinData,
/,
*,
http: HTTPClient,
) -> Self:
):
return cls(cls._patch_data(data), http)

_graphql_fields = {
Expand All @@ -81,7 +80,7 @@ def _from_data(

@property
def created_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -94,7 +93,7 @@ def created_at(

@property
def database_id(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -107,7 +106,7 @@ def database_id(

@property
def updated_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -119,7 +118,7 @@ def updated_at(
return github.utility.iso_to_datetime(self._data["updatedAt"])

async def fetch_created_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand All @@ -146,7 +145,7 @@ async def fetch_created_at(
return github.utility.iso_to_datetime(created_at)

async def fetch_database_id(
self: Self,
self,
/,
) -> int:
"""
Expand All @@ -168,7 +167,7 @@ async def fetch_database_id(
return await self._fetch_field("databaseId") # type: ignore

async def fetch_updated_at(
self: Self,
self,
/,
) -> DateTime:
"""
Expand Down
2 changes: 1 addition & 1 deletion github/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from github.connection.vulnerabilityorder import __all__ as _vulnerabilityorder__all__


__all__: list[str] = [ # type: ignore[reportUnsupportedDunderAll]
__all__ = [ # type: ignore[reportUnsupportedDunderAll]
*_advisoryorder__all__,
*_connection__all__,
*_discussionorder__all__,
Expand Down
2 changes: 1 addition & 1 deletion github/connection/advisoryorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class AdvisoryOrder(enum.Enum):


__all__ = [
"AdvisoryOrder"
"AdvisoryOrder",
]
Loading

0 comments on commit c977697

Please sign in to comment.