Skip to content

Commit

Permalink
ci: fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
micha91 committed Sep 3, 2024
1 parent 398a536 commit d847b95
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
8 changes: 6 additions & 2 deletions capella2polarion/connectors/polarion_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from capella2polarion import data_models
from capella2polarion.connectors import polarion_repo
from capella2polarion.converters import data_session, polarion_html_helper
from capella2polarion.converters import data_session

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -486,7 +486,11 @@ def update_documents(
client.work_items.update(headings)
client.documents.update(documents)

def _process_document_datas(self, client, document_datas):
def _process_document_datas(
self,
client: polarion_api.ProjectClient,
document_datas: list[data_models.DocumentData],
):
documents = []
headings = []
for document_data in document_datas:
Expand Down
15 changes: 7 additions & 8 deletions capella2polarion/converters/link_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
from capellambse.model import common
from capellambse.model import diagram as diag

import capella2polarion.converters.polarion_html_helper
from capella2polarion import data_models
from capella2polarion.connectors import polarion_repo
from capella2polarion.converters import converter_config, data_session
from capella2polarion.converters import (
converter_config,
data_session,
polarion_html_helper,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -346,9 +349,7 @@ def _group_by(
def _make_url_list(link_map: dict[str, dict[str, list[str]]]) -> str:
urls: list[str] = []
for link_id in sorted(link_map):
url = capella2polarion.converters.polarion_html_helper.POLARION_WORK_ITEM_URL.format( # pylint: disable=line-too-long
pid=link_id
)
url = polarion_html_helper.POLARION_WORK_ITEM_URL.format(pid=link_id)
urls.append(f"<li>{url}</li>")
for key, include_wids in link_map[link_id].items():
_, display_name, _ = key.split(":")
Expand All @@ -365,9 +366,7 @@ def _sorted_unordered_html_list(
) -> str:
urls: list[str] = []
for pid in work_item_ids:
url = capella2polarion.converters.polarion_html_helper.POLARION_WORK_ITEM_URL.format( # pylint: disable=line-too-long
pid=pid
)
url = polarion_html_helper.POLARION_WORK_ITEM_URL.format(pid=pid)
urls.append(f"<li>{url}</li>")

urls.sort()
Expand Down
2 changes: 1 addition & 1 deletion capella2polarion/converters/polarion_html_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def setup_env(self, env: jinja2.Environment):


def remove_table_ids(
html_content: str | list[html.HtmlComment],
html_content: str | list[html.HtmlElement],
) -> list[etree._Element]:
"""Remove the ID field from all tables.
Expand Down
16 changes: 8 additions & 8 deletions capella2polarion/converters/text_work_item_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import polarion_rest_api_client as polarion_api
from lxml import html

from capella2polarion.converters import polarion_html_helper
from capella2polarion.converters import polarion_html_helper as html_helper


class TextWorkItemProvider:
"""Class providing text work items, their generation and insertion."""

def __init__(
self,
text_work_item_id_field: str = polarion_html_helper.TEXT_WORK_ITEM_ID_FIELD,
text_work_item_type: str = polarion_html_helper.TEXT_WORK_ITEM_TYPE,
text_work_item_id_field: str = html_helper.TEXT_WORK_ITEM_ID_FIELD,
text_work_item_type: str = html_helper.TEXT_WORK_ITEM_TYPE,
existing_text_work_items: list[polarion_api.WorkItem] | None = None,
):
self.old_text_work_items: dict[str, polarion_api.WorkItem] = {}
Expand All @@ -40,9 +40,9 @@ def generate_text_work_items(
work_item_id_filter: list[str] | None = None,
):
"""Generate text work items from the provided html."""
content = polarion_html_helper.ensure_fragments(content)
content = html_helper.ensure_fragments(content)
for element in content:
if element.tag != polarion_html_helper.WORK_ITEM_TAG:
if element.tag != html_helper.WORK_ITEM_TAG:
continue

if not (text_id := element.get("id")):
Expand Down Expand Up @@ -88,10 +88,10 @@ def insert_text_work_items(
return

assert document.home_page_content is not None
layout_index = polarion_html_helper.get_layout_index(
layout_index = html_helper.get_layout_index(
"paragraph", document.rendering_layouts, self.text_work_item_type
)
html_fragments = polarion_html_helper.ensure_fragments(
html_fragments = html_helper.ensure_fragments(
document.home_page_content.value
)
new_content = []
Expand All @@ -108,7 +108,7 @@ def insert_text_work_items(
):
new_content.append(
html.fromstring(
polarion_html_helper.POLARION_WORK_ITEM_DOCUMENT.format(
html_helper.POLARION_WORK_ITEM_DOCUMENT.format(
pid=work_item.id,
lid=layout_index,
custom_info="",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def test_update_work_items(
assert base_object.pw.project_client.work_items.update.call_count == 1
assert base_object.pw.project_client.work_items.get.call_count == 1
assert (
base_object.pw.project_client.work_items.attachments.get_all.call_count
base_object.pw.project_client.work_items.attachments.get_all.call_count # pylint: disable=line-too-long
== 0
)
work_item = base_object.pw.project_client.work_items.update.call_args[
Expand Down Expand Up @@ -1017,7 +1017,7 @@ def test_update_links(base_object: BaseObjectContainer):
base_object.mc.converter_session
)
links = (
base_object.pw.project_client.work_items.links.get_all.call_args_list
base_object.pw.project_client.work_items.links.get_all.call_args_list # pylint: disable=line-too-long
)
assert (
base_object.pw.project_client.work_items.links.get_all.call_count
Expand Down

0 comments on commit d847b95

Please sign in to comment.