Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
huonw committed Feb 7, 2024
1 parent c7d6677 commit 4b01dd9
Show file tree
Hide file tree
Showing 82 changed files with 211 additions and 294 deletions.
2 changes: 1 addition & 1 deletion build-support/bin/generate_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _run_pants_help():


def _parse_help_for_options(help: dict, scope: str) -> tuple[frozenset[str], frozenset[str]]:
"""scope represents the goal or subsystem of interest Returns a tuple containing the scoped
"""Scope represents the goal or subsystem of interest Returns a tuple containing the scoped
options, followed by unscoped."""
scoped_help_info = help["scope_to_help_info"][scope]

Expand Down
4 changes: 2 additions & 2 deletions build-support/bin/generate_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def get_default(option: dict) -> Any:
"""Get default value for an option.
Ensure options that depend on any machine specific environment are properly handled. E.g.
`"default": "<buildroot>/.pants.d"` will be expanded to the `"default": "/home/your-user.name/code/pants/.pants.d"`
which is not what we want to have in a public schema.
`"default": "<buildroot>/.pants.d"` will be expanded to the `"default": "/home/your-
user.name/code/pants/.pants.d"` which is not what we want to have in a public schema.
"""
return ENV_SPECIFIC_OPTION_DEFAULTS.get(option["config_key"], option["default"])

Expand Down
8 changes: 4 additions & 4 deletions build-support/bin/terraform_tool_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).
"""Fetch versions of Terraform and format them for use in known_versions.
The main version page lists the available versions in descending order.
It includes stable releases but also various levels of pre-release.
The main version page lists the available versions in descending order. It includes stable releases
but also various levels of pre-release.
Each version links to a version-specific page.
This page includes links to download the binary, sha256sum file, and a signature of the sha256sum file.
Each version links to a version-specific page. This page includes links to download the binary,
sha256sum file, and a signature of the sha256sum file.
"""

import csv
Expand Down
8 changes: 4 additions & 4 deletions build-support/migration-support/fix_deprecated_globs_usage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A script to replace deprecated uses of `globs`, `rglobs`, and `zglobs` in BUILD files with a
direct list of files and globs.
Expand Down Expand Up @@ -77,10 +76,11 @@ class GlobFunction(NamedTuple):
def normalize_rglob(rglob: str) -> str:
"""We must expand rglobs for them to work properly.
In rglobs, * at the beginning of a path component means "any number of directories, including 0".
So every time we see ^*, we need to output "**/*whatever".
In rglobs, * at the beginning of a path component means "any number of directories,
including 0". So every time we see ^*, we need to output "**/*whatever".
See https://github.com/pantsbuild/pants/blob/9832c8f6d8b60648cf906775506864aad0ffdb33/src/python/pants/source/wrapped_globs.py#L303
See
https://github.com/pantsbuild/pants/blob/9832c8f6d8b60648cf906775506864aad0ffdb33/src/python/pants/source/wrapped_globs.py#L303
for the original implementation.
"""
components = rglob.split(os.path.sep)
Expand Down
1 change: 0 additions & 1 deletion build-support/migration-support/migrate_to_toml_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

"""A script to automatically convert an INI Pants config file to TOML. There will still likely be
some issues remaining which require manual fixes, but this script will automate most of the tedium.
Expand Down
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 @@ -37,7 +37,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
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 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 @@ -36,7 +36,7 @@ def two_groups_hyphens_two_replacements_with_suffix(
second_group_replacement: str = "",
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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 @@ -104,8 +104,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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def config_request(self) -> ConfigFilesRequest:
"""Pytype will look for a `pyproject.toml` (with a `[tool.pytype]` section) in the project
root.
Pytype's configuration content is specified here: https://github.com/google/pytype#config-
Pytype's configuration content is specified here:
https://github.com/google/pytype#config-
file.
"""

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 @@ -163,8 +163,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 will convert a ctrl-c from the user into a SIGINT.
"""
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
Loading

0 comments on commit 4b01dd9

Please sign in to comment.