Skip to content

Commit

Permalink
formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheppsu committed Oct 9, 2024
1 parent bac231c commit 79c62a1
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
9 changes: 5 additions & 4 deletions osu/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def from_credentials(
code: Optional[str] = None,
request_wait_time: float = 1.0,
limit_per_minute: int = 60,
lazily_authenticate: bool = True
lazily_authenticate: bool = True,
) -> Union["AsynchronousClient", Awaitable]:
"""
Creates client from client id, client secret, redirect uri, and scope.
Expand Down Expand Up @@ -147,6 +147,7 @@ def from_credentials(
"""
auth = AsynchronousAuthHandler(client_id, client_secret, redirect_url, scope)
if not lazily_authenticate:

async def create():
await auth.get_auth_token(code)
return cls(auth, request_wait_time, limit_per_minute)
Expand Down Expand Up @@ -268,9 +269,9 @@ def _parse_mods_list(self, mods) -> Optional[List[str]]:
return
return list(
map(
lambda mod: (Mod[mod.name].value if not isinstance(mod, Mod) else mod.value)
if type(mod) != str
else mod,
lambda mod: (
(Mod[mod.name].value if not isinstance(mod, Mod) else mod.value) if type(mod) != str else mod
),
mods,
)
)
Expand Down
8 changes: 4 additions & 4 deletions osu/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def from_credentials(
code: Optional[str] = None,
request_wait_time: float = 1.0,
limit_per_minute: int = 60,
lazily_authenticate: bool = True
lazily_authenticate: bool = True,
) -> "Client":
"""
Returns a :class:`Client` object from client id, client secret, redirect uri, and scope.
Expand Down Expand Up @@ -243,9 +243,9 @@ def _parse_mods_list(self, mods) -> Optional[List[str]]:
return
return list(
map(
lambda mod: (Mod[mod.name].value if not isinstance(mod, Mod) else mod.value)
if type(mod) != str
else mod,
lambda mod: (
(Mod[mod.name].value if not isinstance(mod, Mod) else mod.value) if type(mod) != str else mod
),
mods,
)
)
Expand Down
4 changes: 3 additions & 1 deletion osu/objects/beatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ def __init__(self, data):
self.is_scoreable: bool = get_required(data, "is_scoreable")
self.last_updated: Optional[datetime] = get_optional(data, "last_updated", parser.parse)
self.legacy_thread_url: Optional[str] = get_required(data, "legacy_thread_url")
self.nominations_summary: BeatmapsetRequirement = BeatmapsetRequirement(get_required(data, "nominations_summary"))
self.nominations_summary: BeatmapsetRequirement = BeatmapsetRequirement(
get_required(data, "nominations_summary")
)
self.ranked: RankStatus = RankStatus(get_required(data, "ranked"))
self.ranked_date: Optional[datetime] = get_optional(data, "ranked_date", parser.parse)
self.storyboard: bool = get_required(data, "storyboard")
Expand Down
4 changes: 3 additions & 1 deletion osu/objects/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ class CommentBundle:
)

def __init__(self, data):
self.commentable_meta: List[CommentableMeta] = list(map(CommentableMeta, get_required(data, "commentable_meta")))
self.commentable_meta: List[CommentableMeta] = list(
map(CommentableMeta, get_required(data, "commentable_meta"))
)
self.comments: List[Comment] = list(map(Comment, get_required(data, "comments")))
self.has_more: bool = get_required(data, "has_more")
self.has_more_id: int = get_required(data, "has_more_id")
Expand Down
4 changes: 3 additions & 1 deletion osu/objects/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ def __init__(self, data):
self.timestamp: datetime = parser.parse(get_required(data, "timestamp"))
self.user_id: int = get_required(data, "user_id")
self.type: MatchEventType = MatchEventType(get_required(data, "detail")["type"])
self.text: Optional[str] = get_required(data, "detail")["text"] if "text" in get_required(data, "detail") else None
self.text: Optional[str] = (
get_required(data, "detail")["text"] if "text" in get_required(data, "detail") else None
)
self.game: Optional[MatchGame] = get_optional(data, "game", MatchGame)

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion osu/objects/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class SoloScore:
"current_user_attributes",
"weight",
"beatmap",
"beatmapset"
"beatmapset",
)

def __init__(self, data):
Expand Down
8 changes: 5 additions & 3 deletions osu/objects/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class User(UserCompact):
"title",
"title_url",
"twitter",
"website"
"website",
)

def __init__(self, data):
Expand Down Expand Up @@ -758,7 +758,9 @@ def __init__(self, data):
self.country_rank: Optional[int] = data.get("country_rank")
self.global_rank: Optional[int] = get_required(data, "global_rank")
self.global_rank_exp: Optional[int] = data.get("global_rank_exp")
self.grade_counts: NamedTuple = namedtuple("GradeCounts", ("ssh", "ss", "sh", "s", "a"))(**get_required(data, "grade_counts"))
self.grade_counts: NamedTuple = namedtuple("GradeCounts", ("ssh", "ss", "sh", "s", "a"))(
**get_required(data, "grade_counts")
)
self.level: NamedTuple = namedtuple("Level", ("current", "progress"))(**get_required(data, "level"))
self.hit_accuracy: float = get_required(data, "hit_accuracy")
self.is_ranked: bool = get_required(data, "is_ranked")
Expand Down Expand Up @@ -1032,7 +1034,7 @@ class DailyChallengeUserStats:
"top_50p_placements",
"user_id",
"weekly_streak_best",
"weekly_streak_current"
"weekly_streak_current",
)

def __init__(self, data):
Expand Down
3 changes: 3 additions & 0 deletions osu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,11 @@ def get_optional_list(data: Dict[str, _V], key: str, obj: Callable[[_V], _T]) ->
# if testing, raise an error for expected keys
# otherwise return none to avoid key errors in prod
if os.getenv("OSUPY_TEST") is None:

def get_required(data: Dict[str, _V], key: str):
return data.get(key)

else:

def get_required(data: Dict[str, _V], key: str):
return data[key]

0 comments on commit 79c62a1

Please sign in to comment.