Skip to content

Commit c7d0003

Browse files
committed
fix: Pre-commit and Lint
1 parent c194516 commit c7d0003

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

polarion_rest_api_client/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import random
1111
import time
1212
import typing as t
13-
import urllib
13+
import urllib.parse
1414

1515
from polarion_rest_api_client import base_client
1616
from polarion_rest_api_client import data_models as dm
1717
from polarion_rest_api_client import errors
1818
from polarion_rest_api_client.open_api_client import client as oa_client
1919
from polarion_rest_api_client.open_api_client import models as api_models
2020
from polarion_rest_api_client.open_api_client import types as oa_types
21+
from polarion_rest_api_client.open_api_client.api.documents import get_document
2122
from polarion_rest_api_client.open_api_client.api.linked_work_items import (
2223
delete_linked_work_items,
2324
get_linked_work_items,
@@ -36,7 +37,6 @@
3637
patch_work_item,
3738
post_work_items,
3839
)
39-
from polarion_rest_api_client.open_api_client.api.documents import get_document
4040

4141
logger = logging.getLogger(__name__)
4242

@@ -649,7 +649,7 @@ def get_document(
649649
include: str | None = None,
650650
revision: str | None = None,
651651
retry: bool = True,
652-
) -> base_client.DocumentType:
652+
) -> dm.Document:
653653
"""Return the document with the given document_name and space_id."""
654654

655655
if " " in space_id or " " in document_name:
@@ -688,7 +688,7 @@ def get_document(
688688
assert (attributes := data.attributes)
689689
assert isinstance(data.id, str)
690690

691-
document: base_client.DocumentType = dm.Document(
691+
document: dm.Document = dm.Document(
692692
id=data.id,
693693
module_folder=unset_str_builder(attributes.module_folder),
694694
module_name=unset_str_builder(attributes.module_name),

polarion_rest_api_client/data_models.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111

1212
class BaseItem:
13+
"""A parent data class for WorkItem and Document."""
14+
1315
id: str | None = None
1416
type: str | None = None
1517
status: str | None = None
@@ -37,7 +39,7 @@ def __eq__(self, other: object) -> bool:
3739

3840
return self.get_current_checksum() == other.get_current_checksum()
3941

40-
def to_dict(self) -> dict[str, Any]:
42+
def to_dict(self) -> dict[str, t.Any]:
4143
"""Return the content of the BaseItem as dictionary."""
4244
return {
4345
"id": self.id,
@@ -72,7 +74,7 @@ class WorkItem(BaseItem):
7274
title: str | None = None
7375
description_type: str | None = None
7476
description: str | None = None
75-
additional_attributes: dict[str, Any] = {}
77+
additional_attributes: dict[str, t.Any] = {}
7678
linked_work_items: list[WorkItemLink] = []
7779
attachments: list[WorkItemAttachment] = []
7880

@@ -84,7 +86,7 @@ def __init__(
8486
description: str | None = None,
8587
type: str | None = None,
8688
status: str | None = None,
87-
additional_attributes: dict[str, Any] | None = None,
89+
additional_attributes: dict[str, t.Any] | None = None,
8890
linked_work_items: list[WorkItemLink] | None = None,
8991
attachments: list[WorkItemAttachment] | None = None,
9092
**kwargs,
@@ -97,13 +99,13 @@ def __init__(
9799
self.linked_work_items = linked_work_items or []
98100
self.attachments = attachments or []
99101

100-
def __getattribute__(self, item: str) -> Any:
102+
def __getattribute__(self, item: str) -> t.Any:
101103
"""Return all non WorkItem attributes from additional_properties."""
102104
if item.startswith("__") or item in dir(WorkItem):
103105
return super().__getattribute__(item)
104106
return self.additional_attributes.get(item)
105107

106-
def __setattr__(self, key: str, value: Any):
108+
def __setattr__(self, key: str, value: t.Any):
107109
"""Set all non WorkItem attributes in additional_properties."""
108110
if key in dir(WorkItem):
109111
super().__setattr__(key, value)
@@ -141,6 +143,8 @@ class WorkItemAttachment:
141143

142144

143145
class Document(BaseItem):
146+
"""A data class containing all relevant data of a Polarion Document."""
147+
144148
module_folder: str | None = None
145149
module_name: str | None = None
146150
home_page_content: dict | None = None

tests/data/mock_api_responses/get_document.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
"links": {
3434
"self": "server-host-name/application-path/projects/MyProjectId/spaces/MySpaceId/documents/MyDocumentName"
3535
}
36-
}
36+
}

tests/test_client_documents.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest_httpx
99

1010
import polarion_rest_api_client as polarion_api
11-
from polarion_rest_api_client.open_api_client import models as api_models
11+
from polarion_rest_api_client import data_models as dm
1212
from tests import TEST_DOCUMENT_RESPONSE
1313

1414

@@ -19,7 +19,7 @@ def test_get_document_with_all_fields(
1919
with open(TEST_DOCUMENT_RESPONSE, encoding="utf8") as f:
2020
httpx_mock.add_response(json=json.load(f))
2121

22-
document = client.get_document(
22+
document: dm.Document = client.get_document(
2323
"MySpaceId", "MyDocumentName", {"fields[documents]": "@all"}
2424
)
2525

0 commit comments

Comments
 (0)