diff --git a/src/python/pants/backend/python/goals/setup_py.py b/src/python/pants/backend/python/goals/setup_py.py index 5b5c38b3651..d261ce96fd5 100644 --- a/src/python/pants/backend/python/goals/setup_py.py +++ b/src/python/pants/backend/python/goals/setup_py.py @@ -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 diff --git a/src/python/pants/build_graph/build_file_aliases_test.py b/src/python/pants/build_graph/build_file_aliases_test.py index 77443f7bd62..ccba47c34ad 100644 --- a/src/python/pants/build_graph/build_file_aliases_test.py +++ b/src/python/pants/build_graph/build_file_aliases_test.py @@ -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}) diff --git a/src/python/pants/core/goals/export_test.py b/src/python/pants/core/goals/export_test.py index 94c998d14fe..2a99b88eb32 100644 --- a/src/python/pants/core/goals/export_test.py +++ b/src/python/pants/core/goals/export_test.py @@ -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( diff --git a/src/python/pants/engine/target.py b/src/python/pants/engine/target.py index d36de397f39..6dc28f5f9a5 100644 --- a/src/python/pants/engine/target.py +++ b/src/python/pants/engine/target.py @@ -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 = ( diff --git a/src/python/pants/help/help_info_extracter.py b/src/python/pants/help/help_info_extracter.py index 0858f91039c..f212b62c916 100644 --- a/src/python/pants/help/help_info_extracter.py +++ b/src/python/pants/help/help_info_extracter.py @@ -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: diff --git a/src/python/pants/help/maybe_color.py b/src/python/pants/help/maybe_color.py index d0a393c3089..ee96a4287a1 100644 --- a/src/python/pants/help/maybe_color.py +++ b/src/python/pants/help/maybe_color.py @@ -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 diff --git a/src/python/pants/util/filtering.py b/src/python/pants/util/filtering.py index 78668edc148..db9a1195a72 100644 --- a/src/python/pants/util/filtering.py +++ b/src/python/pants/util/filtering.py @@ -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