Skip to content

Commit 10efa70

Browse files
Resolve lint errors
1 parent 1191a11 commit 10efa70

File tree

9 files changed

+180
-156
lines changed

9 files changed

+180
-156
lines changed

tools/pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,14 @@ ignore = [
210210
# back to Python 3.7, you can't actually use the new style of annotations without using the future annotations feature.
211211
"FA100",
212212
"UP045",
213-
"UP006"
213+
"UP006",
214+
"UP007"
215+
]
216+
# Allow "unsafe" fixes to be done automatically for the following:
217+
extend-safe-fixes = [
218+
"W291", # Trailing whitespace
219+
"W293", # Whitespace on blank line
220+
"EM101",# Exception message must be assigned to variable
214221
]
215222

216223
[tool.ruff.lint.mccabe]

tools/python/mbed_tools/build/_internal/config/assemble_build_config.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@
66

77
from __future__ import annotations
88

9-
import itertools
109
import logging
11-
1210
from dataclasses import dataclass
1311
from pathlib import Path
1412
from typing import Iterable, List, Optional, Set
1513

1614
import pydantic
17-
from setuptools.build_meta import build_editable
1815

19-
from mbed_tools.build._internal.config.schemas import MbedAppJSON
20-
from mbed_tools.lib.json_helpers import decode_json_file
21-
from mbed_tools.project import MbedProgram
16+
from mbed_tools.build._internal.config import source
2217
from mbed_tools.build._internal.config.config import Config
18+
from mbed_tools.build._internal.config.schemas import MbedAppJSON
2319
from mbed_tools.build._internal.find_files import LabelFilter, filter_files, find_files
20+
from mbed_tools.lib.json_helpers import decode_json_file
2421
from mbed_tools.project import MbedProgram
2522

2623
logger = logging.getLogger(__name__)
@@ -98,12 +95,12 @@ def _assemble_config_from_sources(
9895
# if it does not pass the schema. This provides compatibility with older projects, as mbed_app.json has
9996
# historically been a total wild west where any internal Mbed state could potentially be overridden.
10097
try:
101-
MbedAppJSON.model_validate(mbed_app_json_dict, strict=True)
98+
_ = MbedAppJSON.model_validate(mbed_app_json_dict, strict=True)
10299
except pydantic.ValidationError as ex:
103100
logger.warning(
104101
"mbed_app.json5 failed to validate against the schema. This likely means it contains deprecated attributes, misspelled attributes, or overrides for things that should not be set in mbed_app.json5. This version of mbed-os still allows this, but this will change in the future."
105102
)
106-
logger.warning("Error was: " + str(ex))
103+
logger.warning("Error was: %s", str(ex))
107104

108105
app_data = source.prepare(
109106
"mbed_app.json5", mbed_app_json_dict, source_name="app", target_filters=filter_data.labels
@@ -123,7 +120,7 @@ class FileFilterData:
123120
requires: Set[str]
124121

125122
@classmethod
126-
def from_config(cls, config: Config) -> "FileFilterData":
123+
def from_config(cls, config: Config) -> FileFilterData:
127124
"""Extract file filters from a Config object."""
128125
return cls(
129126
labels=config.get("labels", set()) | config.get("extra_labels", set()),

tools/python/mbed_tools/build/_internal/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _handle_overrides(self, overrides: Iterable[Override]) -> None:
6262
_apply_override(self.data, override)
6363
continue
6464

65-
setting: ConfigSetting = next(
65+
setting: ConfigSetting | None = next(
6666
filter(
6767
lambda x: x.name == override.name and x.namespace == override.namespace,
6868
self.data.get(CONFIG_SECTION, []),

0 commit comments

Comments
 (0)