Skip to content

Commit dc54290

Browse files
authored
Fix Black linter (aws-observability#9)
The Black linter was configured with an "exclude" file that was not correctly made - it was excluding anything with "dist" in the path, which included eachdist.py and the opentelemetry-distro directory. By default[1], Black uses the .gitignore file, which is a superset of what was specified in the exclude file, so just use that. Also ran and applied the linter. [1] https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
2 parents 8409a7f + 910b22d commit dc54290

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_configurator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88

99
class AwsTracerProvider(TracerProvider):
10-
def __init__(
11-
self
12-
):
10+
def __init__(self):
1311
pass
1412
# TODO:
1513
# 1. Add SpanMetricsProcessor to generate AppSignal metrics from spans and exports them

pyproject.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
[tool.black]
22
line-length = 120
3-
exclude = '''
4-
(
5-
\.git
6-
| \.tox
7-
| venv
8-
| build
9-
| dist
10-
)
11-
'''

scripts/eachdist.py

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,11 @@ def parse_args(args=None):
185185
),
186186
)
187187

188-
instparser = subparsers.add_parser(
189-
"install", help="Install all distributions."
190-
)
188+
instparser = subparsers.add_parser("install", help="Install all distributions.")
191189

192190
def setup_instparser(instparser):
193191
instparser.set_defaults(func=install_args)
194-
instparser.add_argument(
195-
"pipargs", nargs=argparse.REMAINDER, help=extraargs_help("pip")
196-
)
192+
instparser.add_argument("pipargs", nargs=argparse.REMAINDER, help=extraargs_help("pip"))
197193

198194
setup_instparser(instparser)
199195
instparser.add_argument("--editable", "-e", action="store_true")
@@ -213,9 +209,7 @@ def setup_instparser(instparser):
213209
with_test_deps=True,
214210
)
215211

216-
lintparser = subparsers.add_parser(
217-
"lint", help="Lint everything, autofixing if possible."
218-
)
212+
lintparser = subparsers.add_parser("lint", help="Lint everything, autofixing if possible.")
219213
lintparser.add_argument("--check-only", action="store_true")
220214
lintparser.set_defaults(func=lint_args)
221215

@@ -224,9 +218,7 @@ def setup_instparser(instparser):
224218
help="Test everything (run pytest yourself for more complex operations).",
225219
)
226220
testparser.set_defaults(func=test_args)
227-
testparser.add_argument(
228-
"pytestargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
229-
)
221+
testparser.add_argument("pytestargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest"))
230222

231223
fmtparser = subparsers.add_parser(
232224
"format",
@@ -263,12 +255,7 @@ def find_targets_unordered(rootpath):
263255

264256

265257
def getlistcfg(strval):
266-
return [
267-
val.strip()
268-
for line in strval.split("\n")
269-
for val in line.split(",")
270-
if val.strip()
271-
]
258+
return [val.strip() for line in strval.split("\n") for val in line.split(",") if val.strip()]
272259

273260

274261
def find_targets(mode, rootpath):
@@ -281,11 +268,7 @@ def find_targets(mode, rootpath):
281268

282269
targets = list(find_targets_unordered(rootpath))
283270
if "extraroots" in mcfg:
284-
targets += [
285-
path
286-
for extraglob in getlistcfg(mcfg["extraroots"])
287-
for path in rootpath.glob(extraglob)
288-
]
271+
targets += [path for extraglob in getlistcfg(mcfg["extraroots"]) for path in rootpath.glob(extraglob)]
289272
if "sortfirst" in mcfg:
290273
sortfirst = getlistcfg(mcfg["sortfirst"])
291274

@@ -319,9 +302,7 @@ def filter_func(path):
319302
for target in targets
320303
for subglob in subglobs
321304
# We need to special-case the dot, because glob fails to parse that with an IndexError.
322-
for subdir in (
323-
(target,) if subglob == "." else target.glob(subglob)
324-
)
305+
for subdir in ((target,) if subglob == "." else target.glob(subglob))
325306
)
326307
if ".egg-info" not in str(newentry) and newentry.exists()
327308
]
@@ -361,9 +342,7 @@ def runsubprocess(dry_run, params, *args, **kwargs):
361342
try:
362343
return subprocess_run(params, *args, check=check, **kwargs)
363344
except OSError as exc:
364-
raise ValueError(
365-
"Failed executing " + repr(params) + ": " + str(exc)
366-
) from exc
345+
raise ValueError("Failed executing " + repr(params) + ": " + str(exc)) from exc
367346

368347

369348
def execute_args(args):
@@ -388,9 +367,7 @@ def fmt_for_path(fmt, path):
388367
)
389368

390369
def _runcmd(cmd):
391-
result = runsubprocess(
392-
args.dry_run, shlex.split(cmd), cwd=rootpath, check=False
393-
)
370+
result = runsubprocess(args.dry_run, shlex.split(cmd), cwd=rootpath, check=False)
394371
if result is not None and result.returncode not in args.allowexitcode:
395372
print(
396373
f"'{cmd}' failed with code {result.returncode}",
@@ -399,9 +376,7 @@ def _runcmd(cmd):
399376
sys.exit(result.returncode)
400377

401378
if args.all:
402-
allstr = args.allsep.join(
403-
fmt_for_path(args.all, path) for path in targets
404-
)
379+
allstr = args.allsep.join(fmt_for_path(args.all, path) for path in targets)
405380
cmd = args.format.format(allstr)
406381
_runcmd(cmd)
407382
else:
@@ -492,8 +467,7 @@ def lint_args(args):
492467

493468
runsubprocess(
494469
args.dry_run,
495-
("black", "--config", f"{rootdir}/pyproject.toml", ".")
496-
+ (("--diff", "--check") if args.check_only else ()),
470+
("black", "--config", f"{rootdir}/pyproject.toml", ".") + (("--diff", "--check") if args.check_only else ()),
497471
cwd=rootdir,
498472
check=True,
499473
)
@@ -509,11 +483,7 @@ def lint_args(args):
509483
("flake8", "--config", f"{rootdir}/.flake8", rootdir),
510484
check=True,
511485
)
512-
execute_args(
513-
parse_subargs(
514-
args, ("exec", "pylint {}", "--all", "--mode", "lintroots")
515-
)
516-
)
486+
execute_args(parse_subargs(args, ("exec", "pylint {}", "--all", "--mode", "lintroots")))
517487
execute_args(
518488
parse_subargs(
519489
args,

0 commit comments

Comments
 (0)