Skip to content

Commit

Permalink
style(lint): manual fixes for ruff 0.6 linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Aug 19, 2024
1 parent 89695be commit 473006d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions craft_parts/plugins/maven_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import os
import re
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Literal, cast
from urllib.parse import urlparse
from xml.etree import ElementTree

from overrides import override

Expand Down Expand Up @@ -139,7 +139,7 @@ def _create_settings(settings_path: Path) -> None:
:param settings_path: the location the settings file will be created.
"""
settings = ElementTree.Element(
settings = ET.Element(
"settings",
attrib={
"xmlns": "http://maven.apache.org/SETTINGS/1.0.0",
Expand All @@ -150,18 +150,18 @@ def _create_settings(settings_path: Path) -> None:
),
},
)
element = ElementTree.Element("interactiveMode")
element = ET.Element("interactiveMode")
element.text = "false"
settings.append(element)
proxies = ElementTree.Element("proxies")
proxies = ET.Element("proxies")

for protocol in ("http", "https"):
env_name = f"{protocol}_proxy"
if env_name not in os.environ:
continue

proxy_url = urlparse(os.environ[env_name])
proxy = ElementTree.Element("proxy")
proxy = ET.Element("proxy")
proxy_tags = [
("id", env_name),
("active", "true"),
Expand All @@ -176,14 +176,14 @@ def _create_settings(settings_path: Path) -> None:
proxy_tags.append(("nonProxyHosts", _get_no_proxy_string()))

for tag, text in proxy_tags:
element = ElementTree.Element(tag)
element = ET.Element(tag)
element.text = text
proxy.append(element)

proxies.append(proxy)

settings.append(proxies)
tree = ElementTree.ElementTree(settings)
tree = ET.ElementTree(settings)
os.makedirs(os.path.dirname(settings_path), exist_ok=True)

with settings_path.open("w") as file:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/plugins/test_maven_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import io
import os
import xml.etree.ElementTree as ET
from pathlib import Path
from textwrap import dedent
from unittest import mock
from xml.etree import ElementTree

import pytest
from craft_parts import Part, PartInfo, ProjectInfo, errors
Expand Down Expand Up @@ -226,7 +226,7 @@ def test_settings_proxy(part_info, protocol, no_proxy, non_proxy_hosts):

def _normalize_settings(settings):
with io.StringIO(settings) as f:
tree = ElementTree.parse(f) # noqa: S314
tree = ET.parse(f) # noqa: S314
for element in tree.iter():
if element.text is not None and element.text.isspace():
element.text = None
Expand Down

0 comments on commit 473006d

Please sign in to comment.