From 104d36407c9a530f1c8156f565c45d9765f85f7b Mon Sep 17 00:00:00 2001 From: psuedomagi Date: Tue, 16 Jan 2024 06:44:25 -0500 Subject: [PATCH] lint everywhere --- fedcal/_base.py | 29 +++++++++++++++++------------ fedcal/_typing.py | 2 +- fedcal/fedstamp.py | 3 +-- fedcal/utils.py | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/fedcal/_base.py b/fedcal/_base.py index 89a617f..86537c8 100644 --- a/fedcal/_base.py +++ b/fedcal/_base.py @@ -25,8 +25,6 @@ from functools import total_ordering from typing import Any, Callable, Generator, Iterable, Mapping, Type -import attr - from fedcal._typing import EnumType @@ -311,7 +309,10 @@ def list_member_attrs(cls, member: EnumType) -> list[Any]: """ Simple classmethod to return the attributes of members. """ - return sorted(member.value + ([getattr(member, attr) for attr in cls._lookup_attributes()])) + return sorted( + member.value + + ([getattr(member, attr) for attr in cls._lookup_attributes()]) + ) @classmethod def members(cls) -> list[Type[EnumType]]: @@ -351,16 +352,21 @@ def val_attr_map(cls) -> Mapping[Any, Any]: Returns ------- - _description_ + Returns dictionary map of member' values to its attributes """ - member_attrs = [cls.list_member_attrs(member=x) if x in cls._member_names_ else None for x in cls._member_names_] - return dict(zip(cls._member_names_, cls._value2member_map_.values(), member_attrs)) - + member_attrs = [ + cls.list_member_attrs(member=x) if x in cls._member_names_ else None + for x in cls._member_names_ + ] + return dict( + zip(cls._member_names_, cls._value2member_map_.values(), member_attrs) + ) @classmethod def attr_member_map(cls, attr: str) -> Mapping[Any, Any]: - return {getattr(cls.members(), attr): item for item in cls.val_attr_map().items()} - + return { + getattr(cls.members(), attr): item for item in cls.val_attr_map().items() + } @classmethod def get_reverse_member_value_map(cls) -> Mapping[Any, Any]: @@ -368,9 +374,8 @@ def get_reverse_member_value_map(cls) -> Mapping[Any, Any]: @classmethod def member_dict(cls) -> Mapping[Any, Any]: - return dict(cls.members(): cls.list_member_attrs(member) for member in cls.members() if member.value is not None) - - + members = cls.members() + return {member: cls.list_member_attrs(member=member) for member in members} __all__: list[str] = ["EnumBase", "HandyEnumMixin", "MagicDelegator"] diff --git a/fedcal/_typing.py b/fedcal/_typing.py index c56ccc8..49cff53 100644 --- a/fedcal/_typing.py +++ b/fedcal/_typing.py @@ -26,7 +26,7 @@ if TYPE_CHECKING: from fedcal.utils import YearMonthDay - from fedcal.enum import Dept, DeptStatus, EnumBase + from fedcal.enum import EnumBase TimestampSeries = "Series[Timestamp]" diff --git a/fedcal/fedstamp.py b/fedcal/fedstamp.py index 2883398..10ae3be 100644 --- a/fedcal/fedstamp.py +++ b/fedcal/fedstamp.py @@ -24,7 +24,6 @@ import pandas as pd from pandas import MultiIndex, Timestamp -from fedcal import offsets, utils from fedcal._base import MagicDelegator from fedcal.enum import Dept, DeptStatus from fedcal._status_factory import fetch_index @@ -355,7 +354,7 @@ def business_day(self) -> bool: True if the date is a business day, False otherwise. """ - b_day: FedBusinessDay = offsets.FedBusinessDay() + b_day: FedBusinessDay = FedBusinessDay() return b_day.is_on_offset(dt=self.ts) # instance cache diff --git a/fedcal/utils.py b/fedcal/utils.py index c7f138f..86262b3 100644 --- a/fedcal/utils.py +++ b/fedcal/utils.py @@ -485,7 +485,7 @@ def to_timestamp(date_input: FedStampConvertibleTypes) -> Timestamp | None: We roll our own here because pd.to_datetime has multiple outputs depending on input type, and we want to consistently get Timestamps and normalize them. This also allows us to add some flexibility to how to_datetime - handles input. + handles input. Parameters ----------