Skip to content

Commit

Permalink
fix: 속성 참조가 불가능한 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
SaidBySolo authored Aug 26, 2023
1 parent ed2a5d9 commit 4aac3dd
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions neispy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def sync(
KEY: Optional[str] = None,
pIndex: int = 1,
pSize: int = 100,
) -> SyncNeispy:
return cast(SyncNeispy, super().sync(KEY, pIndex, pSize))
) -> "SyncNeispy":
return cast("SyncNeispy", super().sync(KEY, pIndex, pSize))

async def schoolInfo(
self,
Expand Down
14 changes: 10 additions & 4 deletions neispy/domain/classinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ class ClassInfoRow(SchoolRelated):
"학년도"
GRADE: str
"학년"
CLASS_NM: str
"학급명"
DDDEP_NM: str
"학과명"
DGHT_CRSE_SC_NM: str
"주야과정명"
SCHUL_CRSE_SC_NM: str
"학교과정명"
ORD_SC_NM: str
"계열명"
DDDEP_NM: str
"학과명"
CLASS_NM: str
"학급명"
LOAD_DTM: str
"수정일"


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion neispy/domain/schoolmajorinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SchoolMajorInfoRow(SchoolRelated):

@dataclass
class SchoolMajorInfo(Deserializer):
schoolMajorInfo: NeisObject[SchoolMajorInfoRow]
schoolMajorinfo: NeisObject[SchoolMajorInfoRow]

@classmethod
def from_dict(cls, d: SchoolMajorInfoDict) -> SchoolMajorInfo:
Expand Down
3 changes: 0 additions & 3 deletions neispy/domain/schoolschedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,3 @@ def from_dict(
cls, d: SchoolScheduleDict
) -> SchoolSchedule: # type: ignore[valid-type]
return super().from_dict(d)


SchoolSchedule.SchoolSchedule[1].row[0].AY
2 changes: 1 addition & 1 deletion neispy/domain/schulaflcoinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SchulAflcoInfoRow(SchoolRelated):

@dataclass
class SchulAflcoInfo(Deserializer):
schulAflcoInfo: NeisObject[SchulAflcoInfoRow]
schulAflcoinfo: NeisObject[SchulAflcoInfoRow]

@classmethod
def from_dict(cls, d: SchulAflcoInfoDict) -> SchulAflcoInfo:
Expand Down
4 changes: 2 additions & 2 deletions neispy/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def sync(
KEY: Optional[str],
pIndex: int,
pSize: int,
) -> SyncNeispyRequest:
) -> "SyncNeispyRequest":
http = cls(KEY, pIndex, pSize, None)
origin_request_func = getattr(http, "request")
loop = get_event_loop()
Expand Down Expand Up @@ -95,7 +95,7 @@ def dont_use_sync(*args: Any, **kwargs: Any) -> NoReturn:
http.__setattr__(method, to_sync_func(getattr(http, method)))

setattr(http.__class__, "sync", property(dont_use_sync))
return cast(SyncNeispyRequest, http)
return cast("SyncNeispyRequest", http)

async def request(
self,
Expand Down
5 changes: 2 additions & 3 deletions neispy/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime, timedelta, timezone
from typing import Any, Tuple
from typing import Any, Tuple, get_type_hints

from typing_extensions import Self

Expand All @@ -15,14 +15,13 @@ def now() -> str:
class Deserializer:
@classmethod
def from_dict(cls, d: Any) -> Self:
annotations = cls.__annotations__
annotations = get_type_hints(cls)
key = list(annotations.keys())[0]
# 유형주석의 첫번째는 튜플형식 입니다.
# 튜플의 첫번째는 Head이고 두번째는 Row입니다.
# 그러므로 __args__[1]을 사용하여 Row를 가져옵니다.
# Row의 제네릭 타입을 가져와서 객체를 생성해야하기 때문에 다시 __args__[0]을 사용합니다.
row_type: AbstractRow = list(annotations.values())[0].__args__[1].__args__[0]

obj: Tuple[Head, Row[Any]] = (
Head.from_dict(d[key][0]),
Row.from_dict([row_type.from_dict(d) for d in d[key][1]["row"]]),
Expand Down

0 comments on commit 4aac3dd

Please sign in to comment.