Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes after pre release review #71

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
env:
PYTHON_VERSION: "3.8"
POETRY_VERSION: "1.8.3"
RUFF_VERSION: "0.5.4"
RUFF_VERSION: "0.6.7"

jobs:
lint:
Expand Down
11 changes: 3 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ repos:
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
rev: v0.6.7
hooks:
- id: ruff
args: [ --fix ]
# Spell Checker
- repo: https://github.com/crate-ci/typos
rev: v1.23.3
rev: v1.24.6
hooks:
- id: typos
# Git commit linter
Expand All @@ -29,7 +29,7 @@ repos:
- id: gitlint
# Detect hardcoded secrets
- repo: https://github.com/zricethezav/gitleaks
rev: v8.18.4
rev: v8.19.2
hooks:
- id: gitleaks
- repo: local
Expand All @@ -41,8 +41,3 @@ repos:
stages: [pre-push]
language: python
types: [python]

ci:
skip: [test, gitlint]
autofix_prs: false
autoupdate_schedule: monthly
179 changes: 92 additions & 87 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@
fake = Faker()


@pytest.fixture()
@pytest.fixture
def response_mock() -> Generator[MockRouter, None, None]:
with respx_mock(base_url=ROOT_URL) as mock_with_base_url:
yield mock_with_base_url


@pytest.fixture()
@pytest.fixture
def response_report_mock() -> Generator[MockRouter, None, None]:
with respx_mock(base_url=REPORT_ROOT_URL) as mock_with_base_url:
yield mock_with_base_url


@pytest.fixture()
@pytest.fixture
def authed_current_user() -> CurrentUser:
auth = TokenAuth(token=FAKE_TOKEN)

return CurrentUser(auth=auth)


@pytest.fixture()
@pytest.fixture
def authed_workspace() -> Workspace:
auth = TokenAuth(token=FAKE_TOKEN)

return Workspace(auth=auth)


@pytest.fixture()
@pytest.fixture
def authed_report_time_entry() -> ReportTimeEntry:
auth = TokenAuth(token=FAKE_TOKEN)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def i_authed_report_time_entry() -> ReportTimeEntry:
return ReportTimeEntry(auth=auth)


@pytest.fixture()
@pytest.fixture
def me_response(i_authed_user: CurrentUser) -> MeResponse:
return i_authed_user.me()


@pytest.fixture()
@pytest.fixture
def me_preferences_response(i_authed_user: CurrentUser) -> MePreferencesResponse:
return i_authed_user.preferences()

Expand Down
35 changes: 35 additions & 0 deletions toggl_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
__version__ = "0.3.0"

from .auth import BasicAuth, TokenAuth
from .entities.report_time_entry import ReportTimeEntry
from .entities.user import CurrentUser
from .entities.workspace import Workspace
from .exceptions import BadRequest, TogglException
from .schemas.current_user import MeResponse
from .schemas.project import ProjectQueryParams, ProjectResponse
from .schemas.report_time_entry import (
SearchReportTimeEntriesRequest,
SearchReportTimeEntriesResponse,
)
from .schemas.time_entry import MeTimeEntryResponse, TimeEntryCreateRequest, TimeEntryRequest
from .schemas.workspace import WorkspaceResponse


__all__ = (
"BasicAuth",
"TokenAuth",
"CurrentUser",
"Workspace",
"ReportTimeEntry",
"SearchReportTimeEntriesResponse",
"SearchReportTimeEntriesRequest",
"WorkspaceResponse",
"ProjectResponse",
"ProjectQueryParams",
"MeTimeEntryResponse",
"TimeEntryRequest",
"TimeEntryCreateRequest",
"MeResponse",
"BadRequest",
"TogglException",
)
11 changes: 8 additions & 3 deletions toggl_python/schemas/current_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
from pydantic.fields import Field
from pydantic_core import Url

# Move application import `toggl_python.schemas.project.ProjectResponse` into a type-checking block
from toggl_python.schemas.project import ProjectResponse # noqa: TCH001
from toggl_python.schemas.time_entry import MeTimeEntryResponse # noqa: TCH001
from toggl_python.schemas.workspace import WorkspaceResponse # noqa: TCH001


class DateFormat(str, Enum):
mdy_slash = "MM/DD/YYYY"
Expand Down Expand Up @@ -99,10 +104,10 @@ class UpdateMeResponse(MeResponseBase):

class MeResponseWithRelatedData(MeResponse):
clients: Optional[List] = None
projects: Optional[List] = None
projects: Optional[List[ProjectResponse]] = None
tags: Optional[List] = None
time_entries: Optional[List] = None
workspaces: List # Default workspace is created after signup,
time_entries: Optional[List[MeTimeEntryResponse]] = None
workspaces: List[WorkspaceResponse] # Default workspace is created after signup,


class UpdateMePasswordRequest(BaseSchema):
Expand Down
8 changes: 4 additions & 4 deletions toggl_python/schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class ProjectResponse(BaseSchema):
active: bool
actual_hours: int
actual_seconds: int
actual_hours: Optional[int]
actual_seconds: Optional[int]
at: datetime
auto_estimates: Optional[bool]
billable: bool
billable: Optional[bool]
can_track_time: bool
client_id: Optional[int]
color: str
Expand All @@ -32,7 +32,7 @@ class ProjectResponse(BaseSchema):
recurring_parameters: Optional[List]
server_deleted_at: Optional[datetime]
start_date: datetime
status: str
status: Optional[str] = None
template: Optional[bool]
template_id: Optional[int]
workspace_id: int
Expand Down
3 changes: 2 additions & 1 deletion toggl_python/schemas/time_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing_extensions import Self

from toggl_python.schemas.base import BaseSchema, SinceParamSchemaMixin
from toggl_python.schemas.project import ProjectResponse # noqa: TCH001


class BulkEditTimeEntriesOperations(str, Enum):
Expand Down Expand Up @@ -107,7 +108,7 @@ class WebTimerTimeEntryResponse(MeTimeEntryResponseBase):

class MeWebTimerResponse(BaseSchema):
clients: Optional[List]
projects: Optional[List]
projects: Optional[List[ProjectResponse]]
tags: List
time_entries: List[WebTimerTimeEntryResponse]

Expand Down