Skip to content

Commit dc5b490

Browse files
committed
chore: ignore ruff warnings for import-outside-top-level
1 parent d21a8bc commit dc5b490

File tree

7 files changed

+45
-45
lines changed

7 files changed

+45
-45
lines changed

packages/sphinx-taskgraph/src/sphinx_taskgraph/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def setup(app):
1010
"""
1111
Entry point for the Sphinx extension.
1212
"""
13-
from .autoschema import SchemaDocumenter
13+
from .autoschema import SchemaDocumenter # noqa: PLC0415
1414

1515
# Register the custom autodocumenter.
1616
app.add_autodocumenter(SchemaDocumenter)

src/taskgraph/decision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def write_artifact(filename, data):
377377
with open(path, "w") as f:
378378
json.dump(data, f, sort_keys=True, indent=2)
379379
elif filename.endswith(".gz"):
380-
import gzip
380+
import gzip # noqa: PLC0415
381381

382382
with gzip.open(path, "wb") as f:
383383
f.write(json.dumps(data)) # type: ignore
@@ -393,7 +393,7 @@ def read_artifact(filename):
393393
with open(path) as f:
394394
return json.load(f)
395395
elif filename.endswith(".gz"):
396-
import gzip
396+
import gzip # noqa: PLC0415
397397

398398
with gzip.open(path, "rb") as f:
399399
return json.load(f)

src/taskgraph/docker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444

4545
def get_image_digest(image_name):
46-
from taskgraph.generator import load_tasks_for_kind
47-
from taskgraph.parameters import Parameters
46+
from taskgraph.generator import load_tasks_for_kind # noqa: PLC0415
47+
from taskgraph.parameters import Parameters # noqa: PLC0415
4848

4949
params = Parameters(
5050
level=os.environ.get("MOZ_SCM_LEVEL", "3"),
@@ -56,9 +56,9 @@ def get_image_digest(image_name):
5656

5757

5858
def load_image_by_name(image_name, tag=None):
59-
from taskgraph.generator import load_tasks_for_kind
60-
from taskgraph.optimize.strategies import IndexSearch
61-
from taskgraph.parameters import Parameters
59+
from taskgraph.generator import load_tasks_for_kind # noqa: PLC0415
60+
from taskgraph.optimize.strategies import IndexSearch # noqa: PLC0415
61+
from taskgraph.parameters import Parameters # noqa: PLC0415
6262

6363
params = Parameters(
6464
level=os.environ.get("MOZ_SCM_LEVEL", "3"),

src/taskgraph/main.py

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def format_taskgraph_labels(taskgraph):
5555

5656

5757
def format_taskgraph_json(taskgraph):
58-
from taskgraph.util import json
58+
from taskgraph.util import json # noqa: PLC0415
5959

6060
return json.dumps(taskgraph.to_json(), sort_keys=True, indent=2)
6161

@@ -69,9 +69,9 @@ def get_filtered_taskgraph(taskgraph, tasksregex, exclude_keys):
6969
Filter all the tasks on basis of a regular expression
7070
and returns a new TaskGraph object
7171
"""
72-
from taskgraph.graph import Graph
73-
from taskgraph.task import Task
74-
from taskgraph.taskgraph import TaskGraph
72+
from taskgraph.graph import Graph # noqa: PLC0415
73+
from taskgraph.task import Task # noqa: PLC0415
74+
from taskgraph.taskgraph import TaskGraph # noqa: PLC0415
7575

7676
if tasksregex:
7777
named_links_dict = taskgraph.graph.named_links_dict()
@@ -117,14 +117,14 @@ def get_filtered_taskgraph(taskgraph, tasksregex, exclude_keys):
117117

118118
def get_taskgraph_generator(root, parameters):
119119
"""Helper function to make testing a little easier."""
120-
from taskgraph.generator import TaskGraphGenerator
120+
from taskgraph.generator import TaskGraphGenerator # noqa: PLC0415
121121

122122
return TaskGraphGenerator(root_dir=root, parameters=parameters)
123123

124124

125125
def format_taskgraph(options, parameters, overrides, logfile=None):
126-
import taskgraph
127-
from taskgraph.parameters import parameters_loader
126+
import taskgraph # noqa: PLC0415
127+
from taskgraph.parameters import parameters_loader # noqa: PLC0415
128128

129129
if logfile:
130130
handler = logging.FileHandler(logfile, mode="w")
@@ -153,7 +153,7 @@ def format_taskgraph(options, parameters, overrides, logfile=None):
153153

154154

155155
def dump_output(out, path=None, params_spec=None):
156-
from taskgraph.parameters import Parameters
156+
from taskgraph.parameters import Parameters # noqa: PLC0415
157157

158158
params_name = Parameters.format_spec(params_spec)
159159
fh = None
@@ -175,7 +175,7 @@ def dump_output(out, path=None, params_spec=None):
175175

176176

177177
def generate_taskgraph(options, parameters, overrides, logdir):
178-
from taskgraph.parameters import Parameters
178+
from taskgraph.parameters import Parameters # noqa: PLC0415
179179

180180
def logfile(spec):
181181
"""Determine logfile given a parameters specification."""
@@ -370,8 +370,8 @@ def logfile(spec):
370370
"when multiple parameters files are passed.",
371371
)
372372
def show_taskgraph(options):
373-
from taskgraph.parameters import Parameters, parameters_loader
374-
from taskgraph.util.vcs import get_repository
373+
from taskgraph.parameters import Parameters, parameters_loader # noqa: PLC0415
374+
from taskgraph.util.vcs import get_repository # noqa: PLC0415
375375

376376
if options.pop("verbose", False):
377377
logging.root.setLevel(logging.DEBUG)
@@ -575,7 +575,7 @@ def show_taskgraph(options):
575575
metavar="context.tar",
576576
)
577577
def build_image(args):
578-
from taskgraph.docker import build_context, build_image
578+
from taskgraph.docker import build_context, build_image # noqa: PLC0415
579579

580580
validate_docker()
581581
if args["context_only"] is None:
@@ -609,7 +609,10 @@ def build_image(args):
609609
"or mozilla-inbound)",
610610
)
611611
def load_image(args):
612-
from taskgraph.docker import load_image_by_name, load_image_by_task_id
612+
from taskgraph.docker import ( # noqa: PLC0415
613+
load_image_by_name,
614+
load_image_by_task_id,
615+
)
613616

614617
if not args.get("image_name") and not args.get("task_id"):
615618
print("Specify either IMAGE-NAME or TASK-ID")
@@ -641,7 +644,7 @@ def validate_docker():
641644
"contents of the tree.",
642645
)
643646
def image_digest(args):
644-
from taskgraph.docker import get_image_digest
647+
from taskgraph.docker import get_image_digest # noqa: PLC0415
645648

646649
try:
647650
digest = get_image_digest(args["image_name"])
@@ -668,7 +671,7 @@ def image_digest(args):
668671
)
669672
@argument("--user", default=None, help="Container user to start shell with.")
670673
def load_task(args):
671-
from taskgraph.docker import load_task
674+
from taskgraph.docker import load_task # noqa: PLC0415
672675

673676
validate_docker()
674677
return load_task(args["task_id"], remove=args["remove"], user=args["user"])
@@ -728,7 +731,7 @@ def load_task(args):
728731
"--verbose", "-v", action="store_true", help="include debug-level logging output"
729732
)
730733
def decision(options):
731-
from taskgraph.decision import taskgraph_decision
734+
from taskgraph.decision import taskgraph_decision # noqa: PLC0415
732735

733736
taskgraph_decision(options)
734737

@@ -753,10 +756,10 @@ def decision(options):
753756
help="parameters file (.yml or .json; see `taskcluster/docs/parameters.rst`)`",
754757
)
755758
def actions(args):
756-
from taskgraph.actions import render_actions_json
757-
from taskgraph.generator import TaskGraphGenerator
758-
from taskgraph.parameters import parameters_loader
759-
from taskgraph.util import json
759+
from taskgraph.actions import render_actions_json # noqa: PLC0415
760+
from taskgraph.generator import TaskGraphGenerator # noqa: PLC0415
761+
from taskgraph.parameters import parameters_loader # noqa: PLC0415
762+
from taskgraph.util import json # noqa: PLC0415
760763

761764
if args.pop("verbose", False):
762765
logging.root.setLevel(logging.DEBUG)
@@ -782,9 +785,9 @@ def actions(args):
782785
help="root of the taskgraph definition relative to topsrcdir",
783786
)
784787
def action_callback(options):
785-
from taskgraph.actions import trigger_action_callback
786-
from taskgraph.actions.util import get_parameters
787-
from taskgraph.util import json
788+
from taskgraph.actions import trigger_action_callback # noqa: PLC0415
789+
from taskgraph.actions.util import get_parameters # noqa: PLC0415
790+
from taskgraph.util import json # noqa: PLC0415
788791

789792
try:
790793
# the target task for this action (or null if it's a group action)
@@ -831,10 +834,10 @@ def action_callback(options):
831834
@argument("--input", default=None, help="Action input (.yml or .json)")
832835
@argument("callback", default=None, help="Action callback name (Python function name)")
833836
def test_action_callback(options):
834-
import taskgraph.actions
835-
import taskgraph.parameters
836-
from taskgraph.config import load_graph_config
837-
from taskgraph.util import json, yaml
837+
import taskgraph.actions # noqa: PLC0415
838+
import taskgraph.parameters # noqa: PLC0415
839+
from taskgraph.config import load_graph_config # noqa: PLC0415
840+
from taskgraph.util import json, yaml # noqa: PLC0415
838841

839842
def load_data(filename):
840843
with open(filename) as f:
@@ -900,10 +903,10 @@ def load_data(filename):
900903
help=argparse.SUPPRESS, # used for testing
901904
)
902905
def init_taskgraph(options):
903-
from cookiecutter.main import cookiecutter
906+
from cookiecutter.main import cookiecutter # noqa: PLC0415
904907

905-
import taskgraph
906-
from taskgraph.util.vcs import get_repository
908+
import taskgraph # noqa: PLC0415
909+
from taskgraph.util.vcs import get_repository # noqa: PLC0415
907910

908911
repo = get_repository(os.getcwd())
909912
root = Path(repo.path)

src/taskgraph/optimize/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def optimize_task_graph(
5656
assigned taskId, including replacement tasks.
5757
"""
5858
# avoid circular import
59-
from taskgraph.optimize.strategies import IndexSearch
59+
from taskgraph.optimize.strategies import IndexSearch # noqa: PLC0415
6060

6161
label_to_taskid = {}
6262
if not existing_tasks:
@@ -294,7 +294,7 @@ def replace_tasks(
294294
a side-effect.
295295
"""
296296
# avoid circular import
297-
from taskgraph.optimize.strategies import IndexSearch
297+
from taskgraph.optimize.strategies import IndexSearch # noqa: PLC0415
298298

299299
opt_counts = defaultdict(int)
300300
replaced = set()

test/mockedopen.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Imported from
66
# https://searchfox.org/mozilla-central/rev/c3ebaf6de2d481c262c04bb9657eaf76bf47e2ac/config/mozunit/mozunit/mozunit.py#116-232
77

8+
import builtins
89
import os
910
import sys
1011
from io import StringIO
@@ -85,8 +86,6 @@ def __call__(self, name, mode="r"):
8586
return file
8687

8788
def __enter__(self):
88-
import builtins
89-
9089
self.open = builtins.open
9190
self._orig_path_exists = os.path.exists
9291
self._orig_path_isdir = os.path.isdir
@@ -97,8 +96,6 @@ def __enter__(self):
9796
os.path.isfile = self._wrapped_isfile
9897

9998
def __exit__(self, type, value, traceback):
100-
import builtins
101-
10299
builtins.open = self.open
103100
os.path.exists = self._orig_path_exists
104101
os.path.isdir = self._orig_path_isdir

test/test_util_python_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_find_object_no_such_object():
2727

2828
def test_find_object_exists():
2929
"""find_object finds an existing object"""
30-
from testmod.thing import TestObject
30+
from testmod.thing import TestObject # noqa: PLC0415
3131

3232
obj = python_path.find_object("testmod.thing:TestObject.testClassProperty")
3333
assert obj is TestObject.testClassProperty

0 commit comments

Comments
 (0)