From 8b142ded55bb5907e4d2bf85cfec03d5b97df597 Mon Sep 17 00:00:00 2001 From: James Roy Date: Mon, 17 Feb 2025 12:13:13 +0800 Subject: [PATCH] style: edtlib: Sort the import statements Sort the import statements to fix the Ruff I001 warning. Signed-off-by: James Roy --- .ruff-excludes.toml | 2 -- .../python-devicetree/src/devicetree/dtlib.py | 5 ++--- .../src/devicetree/edtlib.py | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.ruff-excludes.toml b/.ruff-excludes.toml index 89ac08b7306..a6eb7f689ad 100644 --- a/.ruff-excludes.toml +++ b/.ruff-excludes.toml @@ -437,14 +437,12 @@ ] "./scripts/dts/python-devicetree/src/devicetree/dtlib.py" = [ "E701", # https://docs.astral.sh/ruff/rules/multiple-statements-on-one-line-colon - "I001", # https://docs.astral.sh/ruff/rules/unsorted-imports "SIM201", # https://docs.astral.sh/ruff/rules/negate-equal-op "UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation ] "./scripts/dts/python-devicetree/src/devicetree/edtlib.py" = [ "B904", # https://docs.astral.sh/ruff/rules/raise-without-from-inside-except "E713", # https://docs.astral.sh/ruff/rules/not-in-test - "I001", # https://docs.astral.sh/ruff/rules/unsorted-imports "SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if "SIM118", # https://docs.astral.sh/ruff/rules/in-dict-keys "UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation diff --git a/scripts/dts/python-devicetree/src/devicetree/dtlib.py b/scripts/dts/python-devicetree/src/devicetree/dtlib.py index 98203768cc5..085d58249ae 100644 --- a/scripts/dts/python-devicetree/src/devicetree/dtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/dtlib.py @@ -20,9 +20,8 @@ import re import string import sys import textwrap -from typing import (Any, Iterable, - NamedTuple, NoReturn, Optional, - TYPE_CHECKING, Union) +from collections.abc import Iterable +from typing import TYPE_CHECKING, Any, NamedTuple, NoReturn, Optional, Union # NOTE: tests/test_dtlib.py is the test suite for this library. diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index b2c718b4d9f..9a3bca7ae41 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -67,31 +67,32 @@ bindings_from_paths() helper function. # @properties are documented in the class docstring, as if they were # variables. See the existing @properties for a template. -from collections import defaultdict -from copy import deepcopy -from dataclasses import dataclass -from typing import (Any, Callable, Iterable, NoReturn, - Optional, TYPE_CHECKING, Union) import base64 import hashlib -from collections.abc import Callable, Iterable import logging import os import re +from collections import defaultdict +from collections.abc import Callable, Iterable +from copy import deepcopy +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any, NoReturn, Optional, Union import yaml + try: # Use the C LibYAML parser if available, rather than the Python parser. # This makes e.g. gen_defines.py more than twice as fast. from yaml import CLoader as Loader except ImportError: - from yaml import Loader # type: ignore + from yaml import Loader # type: ignore -from devicetree.dtlib import DT, DTError, to_num, to_nums, Type +from devicetree._private import _slice_helper +from devicetree.dtlib import DT, DTError, Type, to_num, to_nums from devicetree.dtlib import Node as dtlib_Node from devicetree.dtlib import Property as dtlib_Property from devicetree.grutils import Graph -from devicetree._private import _slice_helper + def _compute_hash(path: str) -> str: # Calculates the hash associated with the node's full path.