Skip to content

Commit 9b91d1a

Browse files
therveci.datadog-api-spec
andauthored
Use ruff format instead of black (#1750)
* Use ruff format instead of black * pre-commit fixes * pre-commit fixes * Try to skip exit failure * pre-commit fixes --------- Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 71a12a1 commit 9b91d1a

File tree

7 files changed

+20
-33
lines changed

7 files changed

+20
-33
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ repos:
4646
pass_filenames: false
4747
additional_dependencies:
4848
- "poetry"
49-
- repo: https://github.com/psf/black
50-
rev: 23.3.0
51-
hooks:
52-
- id: black
53-
stages: [manual]
54-
entry: black --fast --line-length 120 src examples tests
55-
files: '^(src|examples|tests)'
56-
pass_filenames: false
57-
- repo: https://github.com/charliermarsh/ruff-pre-commit
58-
rev: v0.0.275
49+
- repo: https://github.com/astral-sh/ruff-pre-commit
50+
rev: v0.1.4
5951
hooks:
6052
- id: ruff
6153
entry: ruff --fix --quiet --exit-zero --fixable I001,F401 --ignore E501 src examples tests
54+
pass_filenames: false
55+
- id: ruff-format
56+
entry: ruff format src examples tests
57+
pass_filenames: false
58+

generate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ pre_commit_wrapper generator
2828
pre_commit_wrapper examples
2929
pre_commit_wrapper docs
3030
pre_commit_wrapper ruff
31-
pre_commit_wrapper black
31+
pre_commit_wrapper ruff-format 1
3232
pre_commit_wrapper api-docs

ruff.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
line-length = 120

setup.cfg

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,3 @@ datadog_api_client = py.typed
7777

7878
[tool:pytest]
7979
# addopts = --black --cov=datadog_api_client --cov-config .coveragerc --cov-report=term-missing
80-
81-
[flake8]
82-
max-line-length = 120
83-
extend-ignore = E203
84-
85-
[tool:black]
86-
line-length = 120
87-
88-
[tool:isort]
89-
multi_line_output = 3
90-
include_trailing_comma = True
91-
force_grid_wrap = 0
92-
use_parentheses = True
93-
line_length = 120

src/datadog_api_client/configuration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,9 @@ def get_host_from_settings(self, index, variables=None, servers=None):
536536

537537
if "enum_values" in variable and used_value not in variable["enum_values"]:
538538
raise ValueError(
539-
"The variable `{}` in the host URL has invalid value "
540-
"{}. Must be {}.".format(variable_name, variables[variable_name], variable["enum_values"])
539+
"The variable `{}` in the host URL has invalid value " "{}. Must be {}.".format(
540+
variable_name, variables[variable_name], variable["enum_values"]
541+
)
541542
)
542543

543544
url = url.replace(f"{{{variable_name}}}", used_value)

src/datadog_api_client/rest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def __init__(self, configuration, pools_size=4, maxsize=4):
9090
key_file=configuration.key_file,
9191
proxy_url=configuration.proxy,
9292
proxy_headers=configuration.proxy_headers,
93-
**addition_pool_args
93+
**addition_pool_args,
9494
)
9595
else:
9696
self.pool_manager = urllib3.PoolManager(
@@ -100,7 +100,7 @@ def __init__(self, configuration, pools_size=4, maxsize=4):
100100
ca_certs=configuration.ssl_ca_cert,
101101
cert_file=configuration.cert_file,
102102
key_file=configuration.key_file,
103-
**addition_pool_args
103+
**addition_pool_args,
104104
)
105105

106106
def request(

tests/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,19 @@ def freezed_time(default_cassette_name, record_mode, vcr):
282282
freeze_file = pathlib.Path(vcr._path).with_suffix(".frozen")
283283
if not freeze_file.exists():
284284
msg = (
285-
"Time file '{}' not found: create one setting `RECORD=true` or "
286-
"ignore it using `RECORD=none`".format(freeze_file)
285+
"Time file '{}' not found: create one setting `RECORD=true` or " "ignore it using `RECORD=none`".format(
286+
freeze_file
287+
)
287288
)
288289
raise RuntimeError(msg)
289290
with freeze_file.open("r") as f:
290291
freeze_at = f.readline().strip()
291292

292293
if not pathlib.Path(vcr._path).exists():
293294
msg = (
294-
"Cassette '{}' not found: create one setting `RECORD=true` or "
295-
"ignore it using `RECORD=none`".format(vcr._path)
295+
"Cassette '{}' not found: create one setting `RECORD=true` or " "ignore it using `RECORD=none`".format(
296+
vcr._path
297+
)
296298
)
297299
raise RuntimeError(msg)
298300

0 commit comments

Comments
 (0)