Skip to content

Commit

Permalink
Lint fixes - suggested by ruff and flake8 (pantsbuild#18681)
Browse files Browse the repository at this point in the history
  • Loading branch information
asherf authored Apr 4, 2023
1 parent b4530b7 commit a57177d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/backend/python/goals/setup_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __init__(
object.__setattr__(
self,
"_pickled_bytes",
pickle.dumps({k: v for k, v in sorted(kwargs.items())}, protocol=4),
pickle.dumps(dict(sorted(kwargs.items())), protocol=4),
)

@memoized_property
Expand Down
7 changes: 5 additions & 2 deletions src/python/pants/build_graph/build_file_aliases_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ def test_bad_context_aware_object_factories(self):
BuildFileAliases(context_aware_object_factories={"george": 1})

def test_merge(self):
e_factory = lambda ctx: "e"
f_factory = lambda ctx: "f"
def e_factory(ctx):
return "e"

def f_factory(ctx):
return "f"

first = BuildFileAliases(objects={"d": 2}, context_aware_object_factories={"e": e_factory})

Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/core/goals/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def test_run_export_rule() -> None:
assert fp.read() == b"BAR"


_e = lambda path, env: make_target(path, path, env)
def _e(path, env):
return make_target(path, path, env)


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/engine/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,7 @@ def validate_resolved_files(self, files: Sequence[str]) -> None:
"""
if self.expected_file_extensions is not None:
bad_files = [
fp for fp in files if not PurePath(fp).suffix in self.expected_file_extensions
fp for fp in files if PurePath(fp).suffix not in self.expected_file_extensions
]
if bad_files:
expected = (
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/help/help_info_extracter.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def stringify_type(t: type) -> str:
def compute_metavar(kwargs):
"""Compute the metavar to display in help for an option registered with these kwargs."""

stringify = lambda t: HelpInfoExtracter.stringify_type(t)
stringify = HelpInfoExtracter.stringify_type

metavar = kwargs.get("metavar")
if not metavar:
Expand Down
5 changes: 4 additions & 1 deletion src/python/pants/help/maybe_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class MaybeColor:

def __init__(self, color: bool) -> None:
self._color = color
noop = lambda x, **_: x

def noop(x, **_):
return x

self.maybe_color = ansicolor if color else noop
self.maybe_cyan = cyan if color else noop
self.maybe_green = green if color else noop
Expand Down
5 changes: 4 additions & 1 deletion src/python/pants/util/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
def _extract_modifier(modified_param: str) -> Tuple[Callable[[bool], bool], str]:
if modified_param.startswith("-"):
return operator.not_, modified_param[1:]
identity_func = lambda x: x

def identity_func(x):
return x

return identity_func, modified_param[1:] if modified_param.startswith("+") else modified_param


Expand Down

0 comments on commit a57177d

Please sign in to comment.