Skip to content

Commit

Permalink
Formatting round 1
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnan-chandra committed Oct 22, 2024
1 parent ca76857 commit 50ffdd5
Show file tree
Hide file tree
Showing 73 changed files with 179 additions and 242 deletions.
1 change: 0 additions & 1 deletion src/python/pants/backend/awslambda/python/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Create AWS Lambdas from Python code.
See https://www.pantsbuild.org/docs/awslambda-python.
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/cc/lint/clangformat/subsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ClangFormat(PythonToolBase):
default_lockfile_resource = ("pants.backend.cc.lint.clangformat", "clangformat.lock")

def config_request(self, dirs: Iterable[str]) -> ConfigFilesRequest:
"""clang-format will use the closest configuration file to the file currently being
"""Clang-format will use the closest configuration file to the file currently being
formatted, so add all of them."""
config_files = (
".clang-format",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Generate Python sources from Protocol Buffers (Protobufs).
See https://www.pantsbuild.org/docs/protobuf.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A formatter for C/C++ (and several other languages).
See https://clang.llvm.org/docs/ClangFormat.html for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A formatter for JS/TS (and several other languages).
See https://prettier.io/ for details.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/experimental/nfpm/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Create apk, archlinux, deb, and rpm system packages.
See https://nfpm.goreleaser.com/ for details on nFPM, including these descriptions of it:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A python "framework" for apps to dynamically load plugins.
See https://github.com/openstack/stevedore for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Autoformatter to automatically add trailing commas to calls and literals.
See https://github.com/asottile/add-trailing-comma for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Linter & formatter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and https://docs.astral.sh/ruff/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Linter & formatter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and https://docs.astral.sh/ruff/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Static type checker for Python, running on NodeJS.
See https://github.com/Microsoft/pyright for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Lightweight static analysis for many languages. Find bug variants with patterns that look like
source code.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A configurable linter for YAML files.
See https://yamllint.readthedocs.io/ for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Create Google Cloud Functions from Python code.
See https://www.pantsbuild.org/docs/google-cloud-function-python.
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/project_info/count_loc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_passthrough_args(rule_runner: RuleRunner) -> None:


def test_files_without_owners(rule_runner: RuleRunner) -> None:
"""cloc works on any readable file in the build root, regardless of whether it's declared in a
"""Cloc works on any readable file in the build root, regardless of whether it's declared in a
BUILD file."""
rule_runner.write_files(
{
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/project_info/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Information on your project, such as listing the targets in your project."""

from pants.backend.project_info import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def two_groups_hyphens_two_replacements_with_suffix(
second_group_replacement: PackageSeparator = PackageSeparator.NONE,
custom_suffix: str = "",
) -> str:
"""take two groups, and by default, the first will have '-' replaced with '.', the second will
"""Take two groups, and by default, the first will have '-' replaced with '.', the second will
have '-' replaced with '' e.g. google-cloud-foo-bar -> group1(google.cloud.)group2(foobar)
>>> two_groups_hyphens_two_replacements_with_suffix(re.match(r"^(google-cloud-)([^.]+)", "google-cloud-foo-bar"))
Expand All @@ -74,7 +74,6 @@ def two_groups_hyphens_two_replacements_with_suffix(
first_group_hyphen_to_underscore = partial(
first_group_hyphen_to_separator, separator=PackageSeparator.UNDERSCORE
)

"""
A mapping of Patterns and their replacements. will be used with `re.sub`.
The match is either a string or a function`(str) -> str`; that takes a re.Match and returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class FirstPartyPythonModuleMapping:
resolves_to_modules_to_providers: FrozenDict[
ResolveName, FrozenDict[str, Tuple[ModuleProvider, ...]]
]

"""A merged mapping of each resolve name to the first-party module names contained and their
owning addresses.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/autoflake/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Autoformatter for removing unused Python imports.
See https://github.com/myint/autoflake for details.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/bandit/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Security linter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/black/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Autoformatter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Python autoformatter for PEP257 docstring conventions.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/flake8/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Linter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/isort/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Autoformatter for Python import statements.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Static analysis tool for checking compliance with Python docstring conventions.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/pylint/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Linter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and https://www.pylint.org.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/pyupgrade/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""https://github.com/asottile/pyupgrade.
A tool to automatically upgrade syntax for newer versions of the language.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/lint/yapf/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Autoformatter for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/providers/pyenv/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def generate_exe(self, plat: Platform) -> str:
If the downloaded artifact is the executable itself, you can leave this unimplemented.
If the downloaded artifact is an archive, this should be overridden to provide a
relative path in the downloaded archive, e.g. `./bin/protoc`.
If the downloaded artifact is an archive, this should be overridden to provide a relative
path in the downloaded archive, e.g. `./bin/protoc`.
"""
return f"./pyenv-{self.version}/bin/pyenv"

Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2014 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Support for Python.
See https://www.pantsbuild.org/docs/python-backend.
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/target_types_rules.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Rules for the core Python target types.
This is a separate module to avoid circular dependencies. Note that all types used by call sites are
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/backend/python/typecheck/mypy/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Type checker for Python.
See https://www.pantsbuild.org/docs/python-linters-and-formatters and
Expand Down
11 changes: 5 additions & 6 deletions src/python/pants/backend/python/util_rules/local_dists_pep660.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,12 @@ class EditableLocalDistsRequest:
class EditableLocalDists:
"""A Digest populated by editable (PEP660) wheels of local dists.
According to PEP660, these wheels should not be exported to users and must be discarded
after install. Anything that uses this should ensure that these wheels get installed and
then deleted.
According to PEP660, these wheels should not be exported to users and must be discarded after
install. Anything that uses this should ensure that these wheels get installed and then deleted.
Installing PEP660 wheels creates an "editable" install such that the sys.path gets
adjusted to include source directories from the build root (not from the sandbox).
This is decidedly not hermetic or portable and should only be used locally.
Installing PEP660 wheels creates an "editable" install such that the sys.path gets adjusted to
include source directories from the build root (not from the sandbox). This is decidedly not
hermetic or portable and should only be used locally.
PEP660 wheels have .dist-info metadata and the .pth files (or similar) that adjust sys.path.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/backend/python/util_rules/package_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class OwnedDependency:
Code in this target is published in the owner's distribution.
The owner of a target T is T's closest filesystem ancestor among the python_distribution
targets that directly or indirectly depend on it (including T itself).
The owner of a target T is T's closest filesystem ancestor among the python_distribution targets
that directly or indirectly depend on it (including T itself).
"""

target: Target
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/backend/python/util_rules/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ async def _find_all_unique_interpreter_constraints(
This will find the constraints for each individual matching field set, and then OR across all
unique constraints. Usually, Pants partitions when necessary so that conflicting interpreter
constraints can be handled gracefully. But in some cases, like the `generate-lockfiles` goal,
we need to combine those targets into a single value. This ORs, so that if you have a
==2.7 partition and ==3.6 partition, for example, we return ==2.7 OR ==3.6.
constraints can be handled gracefully. But in some cases, like the `generate-lockfiles` goal, we
need to combine those targets into a single value. This ORs, so that if you have a ==2.7
partition and ==3.6 partition, for example, we return ==2.7 OR ==3.6.
Returns the global interpreter constraints if no relevant targets were matched.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/python/pants/base/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class CodeRemovedError(Exception):
I.e., that the option/function/module with that removal_version has already been removed.
Note that the code in question may not actually have been excised from the codebase yet, but
it may be at any time.
Note that the code in question may not actually have been excised from the codebase yet, but it
may be at any time.
"""


Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/base/exception_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class SignalHandler:
"""A specification for how to handle a fixed set of nonfatal signals.
This is subclassed and registered with ExceptionSink.reset_signal_handler() whenever the signal
handling behavior is modified for different pants processes, for example in the remote client when
pantsd is enabled. The default behavior is to exit "gracefully" by leaving a detailed log of which
signal was received, then exiting with failure.
handling behavior is modified for different pants processes, for example in the remote client
when pantsd is enabled. The default behavior is to exit "gracefully" by leaving a detailed log
of which signal was received, then exiting with failure.
Note that the terminal converts a ctrl-c from the user into a SIGINT.
"""
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/base/parse_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def create_object(self, alias: str, *args: Any, **kwargs: Any) -> Any:
"""Constructs the type with the given alias using the given args and kwargs.
:API: public
:param alias: The type alias.
:param args: These pass through to the underlying callable object.
:param kwargs: These pass through to the underlying callable object.
Expand Down
6 changes: 3 additions & 3 deletions src/python/pants/build_graph/build_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ class Builder:
def registered_aliases(self) -> BuildFileAliases:
"""Return the registered aliases exposed in BUILD files.
These returned aliases aren't so useful for actually parsing BUILD files.
They are useful for generating online documentation.
These returned aliases aren't so useful for actually parsing BUILD files. They are
useful for generating online documentation.
:returns: A new BuildFileAliases instance containing this BuildConfiguration's
registered alias mappings.
registered alias mappings.
"""
return BuildFileAliases(
objects=self._exposed_object_by_alias.copy(),
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/core/goals/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def materialize(self, console: Console, workspace: Workspace) -> PurePath | None
:param console: A handle to the terminal.
:param workspace: A handle to local disk.
:return: If a report was materialized to disk, the path of the file in the report one might
open first to start examining the report.
open first to start examining the report.
"""
...

Expand Down
1 change: 0 additions & 1 deletion src/python/pants/core/register.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""Core rules for Pants to operate correctly.
These are always activated and cannot be disabled.
Expand Down
3 changes: 2 additions & 1 deletion src/python/pants/core/util_rules/adhoc_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
class PythonBuildStandaloneBinary:
"""A Python interpreter for use by `@rule` code as an alternative to BashBinary scripts.
This interpreter is provided by Python Build Standalone https://gregoryszorc.com/docs/python-build-standalone/main/,
This interpreter is provided by Python Build Standalone
https://gregoryszorc.com/docs/python-build-standalone/main/,
which has a few caveats. Namely it doesn't play nicely with third-party sdists. Meaning Pants'
scripts being run by Python Build Standalone should avoid third-party sdists.
"""
Expand Down
5 changes: 3 additions & 2 deletions src/python/pants/core/util_rules/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,9 @@ def executable_search_path_cache_scope(
session (i.e. Pants run), but we instead settle for every Pantsd lifetime to have more
acceptable performance.
Meanwhile, when running with Docker, we already invalidate whenever the image changes
thanks to https://github.com/pantsbuild/pants/pull/17101.
Meanwhile, when running with Docker, we already invalidate whenever the image changes thanks
to
https://github.com/pantsbuild/pants/pull/17101.
Remote execution often is safe to cache, but depends on the remote execution server.
So, we rely on the user telling us what is safe.
Expand Down
13 changes: 7 additions & 6 deletions src/python/pants/core/util_rules/external_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def generate_exe(self, plat: Platform) -> str:
If the downloaded artifact is the executable itself, you can leave this unimplemented.
If the downloaded artifact is an archive, this should be overridden to provide a
relative path in the downloaded archive, e.g. `./bin/protoc`.
If the downloaded artifact is an archive, this should be overridden to provide a relative
path in the downloaded archive, e.g. `./bin/protoc`.
"""
return f"./{self.generate_url(plat).rsplit('/', 1)[-1]}"

Expand Down Expand Up @@ -378,11 +378,12 @@ class TemplatedExternalTool(ExternalTool, TemplatedExternalToolOptionsMixin):
In addition to ExternalTool functionalities, it is needed to set, e.g.:
default_url_template = "https://tool.url/{version}/{platform}-mytool.zip"
default_url_template = "
https://tool.url/{version}/{platform}-mytool.zip"
default_url_platform_mapping = {
"macos_x86_64": "osx_intel",
"macos_arm64": "osx_arm",
"linux_x86_64": "linux",
"macos_x86_64": "osx_intel",
"macos_arm64": "osx_arm",
"linux_x86_64": "linux",
}
The platform mapping dict is optional.
Expand Down
Loading

0 comments on commit 50ffdd5

Please sign in to comment.