Skip to content

Commit

Permalink
Use builtins types for __slots__ type-hints. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtlo authored Aug 24, 2021
1 parent bf81a18 commit 0978d10
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 55 deletions.
4 changes: 1 addition & 3 deletions aiobungie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: Sequence[str] = (
__all__: tuple[str, ...] = (
# __init__.py
"__about__",
"__author__",
Expand Down Expand Up @@ -67,8 +67,6 @@
"CredentialType",
)

from typing import Sequence

from .client import Client
from .error import *
from .internal.enums import *
Expand Down
2 changes: 0 additions & 2 deletions aiobungie/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from .error import *
from .internal.enums import *
from .client import Client as Client
from typing import Any

__all__: Any
__version__: str
__about__: str
__author__: str
Expand Down
6 changes: 2 additions & 4 deletions aiobungie/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = [
"Client",
]
__all__: list[str] = ["Client"]

import asyncio
import typing
Expand Down Expand Up @@ -56,7 +54,7 @@ class Client(impl.BaseClient):
asyncio event loop.
"""

__slots__: typing.Sequence[str] = ("loop", "http", "_serialize", "_token")
__slots__: tuple[str, ...] = ("loop", "http", "_serialize", "_token")

def __init__(self, token: str, *, loop: asyncio.AbstractEventLoop = None) -> None:
self.loop: asyncio.AbstractEventLoop = ( # asyncio loop.
Expand Down
6 changes: 2 additions & 4 deletions aiobungie/crate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from __future__ import annotations

__all__: Seq[str] = [
__all__: tuple[str, ...] = (
"Application",
"PostActivity",
"Clan",
Expand All @@ -47,9 +47,7 @@
"ProfileComponentImpl",
"Entity",
"HardLinkedMembership",
]

from typing import Sequence as Seq
)

from .activity import Activity
from .activity import PostActivity
Expand Down
14 changes: 9 additions & 5 deletions aiobungie/crate/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from .activity import Activity as Activity, PostActivity as PostActivity
from .application import Application as Application, ApplicationOwner as ApplicationOwner
from .application import (
Application as Application,
ApplicationOwner as ApplicationOwner,
)
from .character import Character as Character, CharacterComponent as CharacterComponent
from .clans import Clan as Clan, ClanMember as ClanMember, ClanOwner as ClanOwner
from .entity import Entity as Entity, InventoryEntity as InventoryEntity
from .player import Player as Player
from .profile import Profile as Profile, ProfileComponentImpl as ProfileComponentImpl
from .user import HardLinkedMembership as HardLinkedMembership, User as User, UserLike as UserLike
from typing import Any

__all__: Any
from .user import (
HardLinkedMembership as HardLinkedMembership,
User as User,
UserLike as UserLike,
)
2 changes: 1 addition & 1 deletion aiobungie/crate/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ("Activity", "PostActivity")
__all__: tuple[str, ...] = ("Activity", "PostActivity")

import typing
from datetime import datetime
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/crate/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ("Application", "ApplicationOwner")
__all__: tuple[str, ...] = ("Application", "ApplicationOwner")

import typing
from datetime import datetime
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/crate/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ("CharacterComponent", "Character")
__all__: tuple[str, ...] = ("CharacterComponent", "Character")

import abc
import datetime
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/crate/clans.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: typing.List[str] = ["Clan", "ClanOwner", "ClanMember", "ClanFeatures"]
__all__: tuple[str, ...] = ("Clan", "ClanOwner", "ClanMember", "ClanFeatures")


import typing
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/crate/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["InventoryEntity", "Entity"]
__all__: tuple[str, ...] = ("InventoryEntity", "Entity")

import abc
import typing
Expand Down
5 changes: 2 additions & 3 deletions aiobungie/crate/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["Player"]
__all__: tuple[str, ...] = ("Player",)


import typing
Expand All @@ -42,7 +42,6 @@
class Player(UserLike):
"""Represents a Bungie Destiny 2 Player."""


icon: Image = attr.field(repr=False, hash=False, eq=False)
"""The player's icon."""

Expand All @@ -57,7 +56,7 @@ class Player(UserLike):

type: MembershipType = attr.field(repr=True, eq=True, hash=False)
"""The profile's membership type."""

@property
def net(self) -> impl.Netrunner:
"""A network state used for making external requests."""
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/crate/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ("Profile", "ProfileComponentImpl")
__all__: tuple[str, ...] = ("Profile", "ProfileComponentImpl")

import abc
import datetime
Expand Down
4 changes: 2 additions & 2 deletions aiobungie/crate/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

from __future__ import annotations

__all__: typing.Sequence[str] = [
__all__: tuple[str, ...] = (
"User",
"PartialUser",
"UserLike",
"HardLinkedMembership",
]
)

import abc
import typing
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = [
__all__: list[str] = [
"AiobungieError",
"PlayerNotFound",
"ActivityNotFound",
Expand Down
4 changes: 1 addition & 3 deletions aiobungie/ext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["Manifest"]

import typing
__all__: tuple[str, ...] = ("Manifest",)

from .meta import Manifest
3 changes: 1 addition & 2 deletions aiobungie/ext/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

from __future__ import annotations


__all__: t.Sequence[str] = ("Manifest",)
__all__: tuple[str, ...] = ("Manifest",)

import logging
import os
Expand Down
4 changes: 2 additions & 2 deletions aiobungie/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from aiobungie.internal.helpers import JsonDict

__all__ = ("HTTPClient",)
__all__: tuple[str, ...] = ("HTTPClient",)

import http
import types
Expand Down Expand Up @@ -84,7 +84,7 @@ async def handle_errors(

class PreLock:

__slots__: typing.Sequence[str] = ("_lock",)
__slots__: tuple[str, ...] = ("_lock",)

def __init__(self, locker: asyncio.Lock) -> None:
self._lock: asyncio.Lock = locker
Expand Down
4 changes: 1 addition & 3 deletions aiobungie/internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

from __future__ import annotations

from typing import Sequence

__all__: Sequence[str] = [
__all__: list[str] = [
"Image",
"enums",
"deprecated",
Expand Down
3 changes: 0 additions & 3 deletions aiobungie/internal/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from . import enums as enums
from .assets import Image as Image
from .helpers import deprecated as deprecated
from typing import Any

__all__: Any
4 changes: 1 addition & 3 deletions aiobungie/internal/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

from __future__ import annotations

__all__: typing.List[str] = ["Image"]

import typing
__all__: list[str] = ["Image"]

from aiobungie import url
from aiobungie.internal import helpers
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/internal/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = (
__all__: tuple[str, ...] = (
"GameMode",
"MembershipType",
"Class",
Expand Down
4 changes: 2 additions & 2 deletions aiobungie/internal/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@

from __future__ import annotations

__all__: typing.Sequence[str] = [
__all__: tuple[str, ...] = (
"deprecated",
"JsonDict",
"JsonList",
"Undefined",
"Unknown",
"just",
"NoneOr",
]
)

import typing
import warnings
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/internal/helpers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Undefined: str = "Undefined"
Unknown: str = ""

def just(lst: list[dict[str, __Any]], lookup: str) -> list[__Any]: ...
def deprecated(func): ...
def deprecated(func): ...
2 changes: 1 addition & 1 deletion aiobungie/internal/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["BaseClient", "Netrunner"]
__all__: tuple[str, ...] = ("BaseClient", "Netrunner")

import typing

Expand Down
2 changes: 1 addition & 1 deletion aiobungie/internal/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["Deserialize"]
__all__: tuple[str, ...] = ("Deserialize",)

import datetime
import logging
Expand Down
3 changes: 1 addition & 2 deletions aiobungie/internal/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = [
__all__: list[str] = [
"format_played",
"from_timestamp",
"clean_date",
Expand All @@ -35,7 +35,6 @@

import calendar
import math
import typing
from datetime import datetime

from dateutil.parser import parse
Expand Down
2 changes: 1 addition & 1 deletion aiobungie/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import annotations

__all__: typing.Sequence[str] = ["BASE", "REST_EP", "OAUTH_EP", "TOKEN_EP"]
__all__: tuple[str, ...] = ("BASE", "REST_EP", "OAUTH_EP", "TOKEN_EP")

import typing

Expand Down

0 comments on commit 0978d10

Please sign in to comment.