Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35873ec

Browse files
authored
Doc: Use proper name capitalization of tooling (Ruff, Black, Flake8) (#10913)
1 parent 608eca5 commit 35873ec

11 files changed

Lines changed: 52 additions & 44 deletions

File tree

.flake8

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# RST flake8-rst-docstrings
99
# TYP flake8-typing-imports
1010

11-
# The following rules are incompatible with or enforced by black:
11+
# The following rules are incompatible with or enforced by Black:
1212
# E203 whitespace before ':' -- scripts only
1313
# E301 expected 1 blank line
1414
# E302 expected 2 blank lines
@@ -31,15 +31,15 @@ extend-ignore = A, D, N8, SIM, RST, TYP, E301, E302, E305, E501
3131
per-file-ignores =
3232
*.py: E203
3333
*.pyi: B, E701, E741, F401, F403, F405
34-
# Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload.
35-
# Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself.
34+
# Since typing.pyi defines "overload" this is not recognized by Flake8 as typing.overload.
35+
# Unfortunately, Flake8 does not allow to "noqa" just a specific error inside the file itself.
3636
# https://github.com/PyCQA/flake8/issues/1079
3737
# F811 redefinition of unused '...'
3838
stdlib/typing.pyi: B, E701, E741, F401, F403, F405, F811
3939
# Generated protobuf files include docstrings
4040
# *_pb2.pyi: B, E701, E741, F401, F403, F405, Y021, Y026, Y053, Y054
4141

42-
# TODO: Re-enable flake8 on generated protobuf files
42+
# TODO: Re-enable Flake8 on generated protobuf files
4343
# after https://github.com/nipunn1313/mypy-protobuf/issues/523 is resolved
4444
exclude = .venv*,.git,*_pb2.pyi
4545
noqa_require_code = true

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- run: ./tests/check_new_syntax.py
4747

4848
flake8:
49-
name: Lint with flake8
49+
name: Lint with Flake8
5050
runs-on: ubuntu-latest
5151
steps:
5252
- uses: actions/checkout@v4

.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"bungcip.better-toml",
2828
// Don't use two mypy extensions simultaneously
2929
"matangover.mypy",
30-
// We use black
30+
// We use Black
3131
"ms-python.autopep8",
3232
// Not using pylint
3333
"ms-python.pylint",

CONTRIBUTING.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ it takes a bit longer. For more details, read below.
2727
### Code away!
2828

2929
Typeshed runs continuous integration (CI) on all pull requests. This means that
30-
if you file a pull request (PR), our full test suite -- including our linter,
31-
`flake8` -- is run on your PR. It also means that bots will automatically apply
32-
changes to your PR (using `black`, `isort` and `ruff`) to fix any formatting issues.
30+
if you file a pull request (PR), our full test suite
31+
-- including our linter, [Flake8](https://github.com/PyCQA/flake8) --
32+
is run on your PR. It also means that bots will automatically apply
33+
changes to your PR (using [Black](https://github.com/psf/black),
34+
[isort](https://github.com/PyCQA/isort) and
35+
[Ruff](https://github.com/astral-sh/ruff)) to fix any formatting issues.
3336
This frees you up to ignore all local setup on your side, focus on the
3437
code and rely on the CI to fix everything, or point you to the places that
3538
need fixing.
@@ -84,16 +87,18 @@ terminal to install all non-pytype requirements:
8487

8588
## Code formatting
8689

87-
The code is formatted using `black` and `isort`. Various other autofixes are
88-
also performed by `ruff`.
90+
The code is formatted using [`Black`](https://github.com/psf/black)
91+
and [`isort`](https://github.com/PyCQA/isort).
92+
Various other autofixes are
93+
also performed by [`Ruff`](https://github.com/astral-sh/ruff).
8994

9095
The repository is equipped with a [`pre-commit.ci`](https://pre-commit.ci/)
9196
configuration file. This means that you don't *need* to do anything yourself to
9297
run the code formatters. When you push a commit, a bot will run those for you
9398
right away and add a commit to your PR.
9499

95100
That being said, if you *want* to run the checks locally when you commit,
96-
you're free to do so. Either run `isort`, `black` and `ruff` manually...
101+
you're free to do so. Either run the following manually...
97102

98103
```bash
99104
(.venv)$ isort .
@@ -104,9 +109,12 @@ you're free to do so. Either run `isort`, `black` and `ruff` manually...
104109
...Or install the pre-commit hooks: please refer to the
105110
[pre-commit](https://pre-commit.com/) documentation.
106111

107-
Our code is also linted using `flake8`, with plugins `flake8-pyi`,
108-
`flake8-bugbear`, and `flake8-noqa`. As with our other checks, running
109-
flake8 before filing a PR is not required. However, if you wish to run flake8
112+
Our code is also linted using [`Flake8`](https://github.com/pycqa/flake8),
113+
with plugins [`flake8-pyi`](https://github.com/pycqa/flake8-pyi),
114+
[`flake8-bugbear`](https://github.com/PyCQA/flake8-bugbear),
115+
and [`flake8-noqa`](https://github.com/plinss/flake8-noqa).
116+
As with our other checks, running
117+
Flake8 before filing a PR is not required. However, if you wish to run Flake8
110118
locally, install the test dependencies as outlined above, and then run:
111119

112120
```bash

pyproject.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ line_length = 130
33
target_version = ["py310"]
44
skip_magic_trailing_comma = true
55
# Exclude protobuf files because they have long line lengths
6-
# Ideally, we could configure black to allow longer line lengths
6+
# Ideally, we could configure Black to allow longer line lengths
77
# for just these files, but doesn't seem possible yet.
88
force-exclude = ".*_pb2.pyi"
99

@@ -13,8 +13,8 @@ combine_as_imports = true
1313
line_length = 130
1414
skip = [".git", ".github", ".venv"]
1515
extra_standard_library = [
16-
"typing_extensions",
1716
"_typeshed",
17+
"typing_extensions",
1818
# Extra modules not recognized by isort
1919
"_ast",
2020
"_bisect",
@@ -56,7 +56,7 @@ extra_standard_library = [
5656
"opcode",
5757
"pyexpat",
5858
]
59-
known_first_party = ["utils", "parse_metadata"]
59+
known_first_party = ["parse_metadata", "utils"]
6060

6161
[tool.ruff]
6262
line-length = 130
@@ -68,33 +68,33 @@ exclude = [
6868
# Ignore generated protobuf stubs
6969
"*_pb2.pyi",
7070
# virtual environment, cache directories, etc.:
71-
"env",
7271
".env",
73-
".venv",
7472
".git",
7573
".mypy_cache",
7674
".pytype",
75+
".venv",
76+
"env",
7777
]
7878

7979
# Only enable rules that have safe autofixes;
8080
# only enable rules that are relevant to stubs
8181
select = [
82-
"F401", # Remove unused imports
83-
"UP004", # Remove explicit `object` inheritance
84-
"UP006", # PEP-585 autofixes
85-
"UP007", # PEP-604 autofixes
86-
"UP013", # Class-based syntax for TypedDicts
87-
"UP014", # Class-based syntax for NamedTuples
88-
"UP019", # Use str over typing.Text
89-
"UP035", # import from typing, not typing_extensions, wherever possible
90-
"UP039", # don't use parens after a class definition with no bases
91-
"PYI009", # use `...`, not `pass`, in empty class bodies
92-
"PYI010", # function bodies must be empty
93-
"PYI012", # class bodies must not contain `pass`
94-
"PYI013", # non-empty class bodies must not contain `...`
95-
"PYI020", # quoted annotations are always unnecessary in stubs
96-
"PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it
97-
"PYI032", # use `object`, not `Any`, as the second parameter to `__eq__`
82+
"F401", # Remove unused imports
83+
"PYI009", # use `...`, not `pass`, in empty class bodies
84+
"PYI010", # function bodies must be empty
85+
"PYI012", # class bodies must not contain `pass`
86+
"PYI013", # non-empty class bodies must not contain `...`
87+
"PYI020", # quoted annotations are always unnecessary in stubs
88+
"PYI025", # always alias `collections.abc.Set` as `AbstractSet` when importing it
89+
"PYI032", # use `object`, not `Any`, as the second parameter to `__eq__`
90+
"UP004", # Remove explicit `object` inheritance
91+
"UP006", # PEP-585 autofixes
92+
"UP007", # PEP-604 autofixes
93+
"UP013", # Class-based syntax for TypedDicts
94+
"UP014", # Class-based syntax for NamedTuples
95+
"UP019", # Use str over typing.Text
96+
"UP035", # import from typing, not typing_extensions, wherever possible
97+
"UP039", # don't use parens after a class definition with no bases
9898
]
9999

100100
[tool.typeshed]

scripts/create_baseline_stubs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def run_stubdefaulter(stub_dir: str) -> None:
6161

6262

6363
def run_black(stub_dir: str) -> None:
64-
print(f"Running black: black {stub_dir}")
64+
print(f"Running Black: black {stub_dir}")
6565
subprocess.run(["black", stub_dir])
6666

6767

@@ -71,7 +71,7 @@ def run_isort(stub_dir: str) -> None:
7171

7272

7373
def run_ruff(stub_dir: str) -> None:
74-
print(f"Running ruff: ruff {stub_dir}")
74+
print(f"Running Ruff: ruff {stub_dir}")
7575
subprocess.run([sys.executable, "-m", "ruff", stub_dir])
7676

7777

@@ -189,7 +189,7 @@ def add_pyright_exclusion(stub_dir: str) -> None:
189189
def main() -> None:
190190
parser = argparse.ArgumentParser(
191191
description="""Generate baseline stubs automatically for an installed pip package
192-
using stubgen. Also run black, isort and ruff. If the name of
192+
using stubgen. Also run Black, isort and Ruff. If the name of
193193
the project is different from the runtime Python package name, you may
194194
need to use --package (example: --package yaml PyYAML)."""
195195
)

scripts/generate_proto_stubs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PYTHON_PROTOBUF_DIR="protobuf-$PYTHON_PROTOBUF_VERSION"
4545
VENV=venv
4646
python3 -m venv "$VENV"
4747
source "$VENV/bin/activate"
48-
pip install -r "$REPO_ROOT/requirements-tests.txt" # for black and isort
48+
pip install -r "$REPO_ROOT/requirements-tests.txt" # for Black and isort
4949

5050
# Install mypy-protobuf
5151
pip install "git+https://github.com/dropbox/mypy-protobuf@$MYPY_PROTOBUF_VERSION"

scripts/runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def main() -> None:
8282
pytype_result: subprocess.CompletedProcess[bytes] | None = None
8383

8484
# Run formatters first. Order matters.
85-
print("\nRunning ruff...")
85+
print("\nRunning Ruff...")
8686
subprocess.run([sys.executable, "-m", "ruff", path])
8787
print("\nRunning isort...")
8888
subprocess.run([sys.executable, "-m", "isort", path])

stdlib/_winapi.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if sys.platform == "win32":
5454
HIGH_PRIORITY_CLASS: Literal[0x80]
5555
INFINITE: Literal[0xFFFFFFFF]
5656
if sys.version_info >= (3, 8):
57-
# Ignore the flake8 error -- flake8-pyi assumes
57+
# Ignore the Flake8 error -- flake8-pyi assumes
5858
# most numbers this long will be implementation details,
5959
# but here we can see that it's a power of 2
6060
INVALID_HANDLE_VALUE: Literal[0xFFFFFFFFFFFFFFFF] # noqa: Y054

test_cases/stdlib/builtins/check_exception_group-py311.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing_extensions import assert_type
66

77
if sys.version_info >= (3, 11):
8-
# This can be removed later, but right now `flake8` does not know
8+
# This can be removed later, but right now Flake8 does not know
99
# about these two classes:
1010
from builtins import BaseExceptionGroup, ExceptionGroup
1111

0 commit comments

Comments
 (0)