Skip to content

Commit 12a8747

Browse files
Add pyproject.fmt to the pre-commit tooling (#10220)
1 parent d32afef commit 12a8747

File tree

3 files changed

+216
-188
lines changed

3 files changed

+216
-188
lines changed

.pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,7 @@ repos:
183183
args: ["--toml=pyproject.toml"]
184184
additional_dependencies:
185185
- tomli
186+
- repo: https://github.com/tox-dev/pyproject-fmt
187+
rev: "v2.5.0"
188+
hooks:
189+
- id: pyproject-fmt

examples/pyproject.toml

+47-22
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fail-under = 10
3636
# from-stdin =
3737

3838
# Files or directories to be skipped. They should be base names, not paths.
39-
ignore = ["CVS"]
39+
ignore = [ "CVS" ]
4040

4141
# Add files or directories matching the regular expressions patterns to the
4242
# ignore-list. The regex matches against paths and can be in Posix or Windows
@@ -47,7 +47,7 @@ ignore = ["CVS"]
4747
# Files or directories matching the regular expression patterns are skipped. The
4848
# regex matches against base names, not paths. The default value ignores Emacs
4949
# file locks
50-
ignore-patterns = ["^\\.#"]
50+
ignore-patterns = [ "^\\.#" ]
5151

5252
# List of module names for which member attributes should not be checked and will
5353
# not be imported (useful for modules/projects where namespaces are manipulated
@@ -119,7 +119,7 @@ attr-naming-style = "snake_case"
119119
# attr-rgx =
120120

121121
# Bad variable names which should always be refused, separated by a comma.
122-
bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"]
122+
bad-names = [ "foo", "bar", "baz", "toto", "tutu", "tata" ]
123123

124124
# Bad variable names regexes, separated by a comma. If names match any regex,
125125
# they will always be refused
@@ -167,7 +167,7 @@ function-naming-style = "snake_case"
167167
# function-rgx =
168168

169169
# Good variable names which should always be accepted, separated by a comma.
170-
good-names = ["i", "j", "k", "ex", "Run", "_"]
170+
good-names = [ "i", "j", "k", "ex", "Run", "_" ]
171171

172172
# Good variable names regexes, separated by a comma. If names match any regex,
173173
# they will always be accepted
@@ -209,7 +209,7 @@ no-docstring-rgx = "^_"
209209
# List of decorators that produce properties, such as abc.abstractproperty. Add
210210
# to this list to register other decorators that produce valid properties. These
211211
# decorators are taken in consideration only for invalid-name.
212-
property-classes = ["abc.abstractproperty"]
212+
property-classes = [ "abc.abstractproperty" ]
213213

214214
# Regular expression matching correct type alias names. If left empty, type alias
215215
# names will be checked with the set naming style.
@@ -231,17 +231,17 @@ variable-naming-style = "snake_case"
231231
# check-protected-access-in-special-methods =
232232

233233
# List of method names used to declare (i.e. assign) instance attributes.
234-
defining-attr-methods = ["__init__", "__new__", "setUp", "asyncSetUp", "__post_init__"]
234+
defining-attr-methods = [ "__init__", "__new__", "setUp", "asyncSetUp", "__post_init__" ]
235235

236236
# List of member names, which should be excluded from the protected access
237237
# warning.
238-
exclude-protected = ["_asdict", "_fields", "_replace", "_source", "_make", "os._exit"]
238+
exclude-protected = [ "_asdict", "_fields", "_replace", "_source", "_make", "os._exit" ]
239239

240240
# List of valid names for the first argument in a class method.
241-
valid-classmethod-first-arg = ["cls"]
241+
valid-classmethod-first-arg = [ "cls" ]
242242

243243
# List of valid names for the first argument in a metaclass class method.
244-
valid-metaclass-classmethod-first-arg = ["mcs"]
244+
valid-metaclass-classmethod-first-arg = [ "mcs" ]
245245

246246
[tool.pylint.design]
247247
# List of regular expressions of class ancestor names to ignore when counting
@@ -286,7 +286,7 @@ min-public-methods = 2
286286

287287
[tool.pylint.exceptions]
288288
# Exceptions that will emit a warning when caught.
289-
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
289+
overgeneral-exceptions = [ "builtins.BaseException", "builtins.Exception" ]
290290

291291
[tool.pylint.format]
292292
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
@@ -345,7 +345,7 @@ max-module-lines = 1000
345345
# known-standard-library =
346346

347347
# Force import order to recognize a module as part of a third party library.
348-
known-third-party = ["enchant"]
348+
known-third-party = [ "enchant" ]
349349

350350
# Couples of modules and preferred modules, separated by a comma.
351351
# preferred-modules =
@@ -357,12 +357,12 @@ logging-format-style = "old"
357357

358358
# Logging modules to check that the string format arguments are in logging
359359
# function parameter format.
360-
logging-modules = ["logging"]
360+
logging-modules = [ "logging" ]
361361

362362
[tool.pylint."messages control"]
363363
# Only show warnings with the listed confidence levels. Leave empty to show all.
364364
# Valid levels: HIGH, CONTROL_FLOW, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
365-
confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED"]
365+
confidence = [ "HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED" ]
366366

367367
# Disable the message, report, category or checker with the given id(s). You can
368368
# either give multiple identifiers separated by comma (,) or put this option
@@ -373,7 +373,18 @@ confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFIN
373373
# --enable=similarities". If you want to run only the classes checker, but have
374374
# no Warning level messages displayed, use "--disable=all --enable=classes
375375
# --disable=W".
376-
disable = ["raw-checker-failed", "bad-inline-option", "locally-disabled", "file-ignored", "suppressed-message", "useless-suppression", "deprecated-pragma", "use-implicit-booleaness-not-comparison-to-string", "use-implicit-booleaness-not-comparison-to-zero", "use-symbolic-message-instead"]
376+
disable = [
377+
"raw-checker-failed",
378+
"bad-inline-option",
379+
"locally-disabled",
380+
"file-ignored",
381+
"suppressed-message",
382+
"useless-suppression",
383+
"deprecated-pragma",
384+
"use-implicit-booleaness-not-comparison-to-string",
385+
"use-implicit-booleaness-not-comparison-to-zero",
386+
"use-symbolic-message-instead",
387+
]
377388

378389
# Enable the message, report, category or checker with the given id(s). You can
379390
# either give multiple identifier separated by comma (,) or put this option
@@ -384,11 +395,20 @@ disable = ["raw-checker-failed", "bad-inline-option", "locally-disabled", "file-
384395
[tool.pylint.method_args]
385396
# List of qualified names (i.e., library.method) which require a timeout
386397
# parameter e.g. 'requests.api.get,requests.api.post'
387-
timeout-methods = ["requests.api.delete", "requests.api.get", "requests.api.head", "requests.api.options", "requests.api.patch", "requests.api.post", "requests.api.put", "requests.api.request"]
398+
timeout-methods = [
399+
"requests.api.delete",
400+
"requests.api.get",
401+
"requests.api.head",
402+
"requests.api.options",
403+
"requests.api.patch",
404+
"requests.api.post",
405+
"requests.api.put",
406+
"requests.api.request",
407+
]
388408

389409
[tool.pylint.miscellaneous]
390410
# List of note tags to take in consideration, separated by a comma.
391-
notes = ["FIXME", "XXX", "TODO"]
411+
notes = [ "FIXME", "XXX", "TODO" ]
392412

393413
# Regular expression of note tags to take in consideration.
394414
# notes-rgx =
@@ -400,7 +420,7 @@ max-nested-blocks = 5
400420
# Complete name of functions that never returns. When checking for inconsistent-
401421
# return-statements if a never returning function is called then it will be
402422
# considered as an explicit return statement and no message will be printed.
403-
never-returning-functions = ["sys.exit", "argparse.parse_error"]
423+
never-returning-functions = [ "sys.exit", "argparse.parse_error" ]
404424

405425
# Let 'consider-using-join' be raised when the separator to join on would be non-
406426
# empty (resulting in expected fixes of the type: ``"- " + " - ".join(items)``)
@@ -471,7 +491,7 @@ spelling-ignore-comment-directives = "fmt: on,fmt: off,noqa:,noqa,nosec,isort:sk
471491
# List of decorators that produce context managers, such as
472492
# contextlib.contextmanager. Add to this list to register other decorators that
473493
# produce valid context managers.
474-
contextmanager-decorators = ["contextlib.contextmanager"]
494+
contextmanager-decorators = [ "contextlib.contextmanager" ]
475495

476496
# List of members which are set dynamically and missed by pylint inference
477497
# system, and so shouldn't trigger E1101 when accessed. Python regular
@@ -493,12 +513,17 @@ ignore-none = true
493513
ignore-on-opaque-inference = true
494514

495515
# List of symbolic message names to ignore for Mixin members.
496-
ignored-checks-for-mixins = ["no-member", "not-async-context-manager", "not-context-manager", "attribute-defined-outside-init"]
516+
ignored-checks-for-mixins = [
517+
"no-member",
518+
"not-async-context-manager",
519+
"not-context-manager",
520+
"attribute-defined-outside-init",
521+
]
497522

498523
# List of class names for which member attributes should not be checked (useful
499524
# for classes with dynamically set attributes). This supports the use of
500525
# qualified names.
501-
ignored-classes = ["optparse.Values", "thread._local", "_thread._local", "argparse.Namespace"]
526+
ignored-classes = [ "optparse.Values", "thread._local", "_thread._local", "argparse.Namespace" ]
502527

503528
# Show a hint with possible names when a member name was not found. The aspect of
504529
# finding the hint is based on edit distance.
@@ -531,7 +556,7 @@ allow-global-unused-variables = true
531556

532557
# List of strings which can identify a callback function by name. A callback name
533558
# must start or end with one of those strings.
534-
callbacks = ["cb_", "_cb"]
559+
callbacks = [ "cb_", "_cb" ]
535560

536561
# A regular expression matching the name of dummy variables (i.e. expected to not
537562
# be used).
@@ -545,4 +570,4 @@ ignored-argument-names = "_.*|^ignored_|^unused_"
545570

546571
# List of qualified module names which can have objects that can redefine
547572
# builtins.
548-
redefining-builtins-modules = ["six.moves", "past.builtins", "future.builtins", "builtins", "io"]
573+
redefining-builtins-modules = [ "six.moves", "past.builtins", "future.builtins", "builtins", "io" ]

0 commit comments

Comments
 (0)