diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 300ceb2..e0203ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,4 +30,5 @@ repos: - --show-error-context - --ignore-missing-imports additional_dependencies: + - types-requests - types-python-dateutil diff --git a/myfitnesspal/client.py b/myfitnesspal/client.py index 096e8b4..b3056f5 100644 --- a/myfitnesspal/client.py +++ b/myfitnesspal/client.py @@ -9,6 +9,7 @@ from http.cookiejar import CookieJar from pathlib import Path from typing import Any, Dict, List, Optional, Union, cast, overload +from urllib import parse import browser_cookie3 import cloudscraper @@ -16,7 +17,6 @@ import requests from measurement.base import MeasureBase from measurement.measures import Energy, Mass, Volume -from six.moves.urllib import parse from . import types from .base import MFPBase @@ -64,7 +64,7 @@ class Client(MFPBase): def __init__( self, - cookiejar: CookieJar = None, + cookiejar: Optional[CookieJar] = None, unit_aware: bool = False, log_requests_to: Path | None = None, ): @@ -624,7 +624,7 @@ def get_measurements( def set_measurements( self, measurement="Weight", - value: float = None, + value: Optional[float] = None, date: Optional[datetime.date] = None, ) -> None: """Sets measurement for today's date.""" diff --git a/myfitnesspal/day.py b/myfitnesspal/day.py index 7e18f39..681603b 100644 --- a/myfitnesspal/day.py +++ b/myfitnesspal/day.py @@ -16,10 +16,10 @@ def __init__( self, date: datetime.date, meals: Optional[List[Meal]] = None, - goals: Dict[str, float] = None, - notes: Callable[[], str] = None, - water: Callable[[], float] = None, - exercises: Callable[[], List[Exercise]] = None, + goals: Optional[Dict[str, float]] = None, + notes: Optional[Callable[[], str]] = None, + water: Optional[Callable[[], float]] = None, + exercises: Optional[Callable[[], List[Exercise]]] = None, complete: bool = False, ): self._date = date diff --git a/myfitnesspal/note.py b/myfitnesspal/note.py index 493fa8e..5ccdd41 100644 --- a/myfitnesspal/note.py +++ b/myfitnesspal/note.py @@ -2,7 +2,7 @@ import datetime from html import unescape -from typing import Dict, Optional +from typing import Optional from .types import NoteDataDict @@ -10,7 +10,7 @@ class Note(str): """Stores information about a note""" - _note_data: Dict[str, str] + _note_data: NoteDataDict def __new__(cls, note_data: NoteDataDict) -> Note: # I'm not sure I understand why this is double-encoded, but it is?