Skip to content

Commit

Permalink
Use ruff format instead of black (#1750)
Browse files Browse the repository at this point in the history
* 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 <packages@datadoghq.com>
  • Loading branch information
therve and ci.datadog-api-spec authored Nov 7, 2023
1 parent 71a12a1 commit 9b91d1a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 33 deletions.
17 changes: 7 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ repos:
pass_filenames: false
additional_dependencies:
- "poetry"
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
stages: [manual]
entry: black --fast --line-length 120 src examples tests
files: '^(src|examples|tests)'
pass_filenames: false
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.275
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: ruff
entry: ruff --fix --quiet --exit-zero --fixable I001,F401 --ignore E501 src examples tests
pass_filenames: false
- id: ruff-format
entry: ruff format src examples tests
pass_filenames: false

2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ pre_commit_wrapper generator
pre_commit_wrapper examples
pre_commit_wrapper docs
pre_commit_wrapper ruff
pre_commit_wrapper black
pre_commit_wrapper ruff-format 1
pre_commit_wrapper api-docs
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
line-length = 120
14 changes: 0 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,3 @@ datadog_api_client = py.typed

[tool:pytest]
# addopts = --black --cov=datadog_api_client --cov-config .coveragerc --cov-report=term-missing

[flake8]
max-line-length = 120
extend-ignore = E203

[tool:black]
line-length = 120

[tool:isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 120
5 changes: 3 additions & 2 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ def get_host_from_settings(self, index, variables=None, servers=None):

if "enum_values" in variable and used_value not in variable["enum_values"]:
raise ValueError(
"The variable `{}` in the host URL has invalid value "
"{}. Must be {}.".format(variable_name, variables[variable_name], variable["enum_values"])
"The variable `{}` in the host URL has invalid value " "{}. Must be {}.".format(
variable_name, variables[variable_name], variable["enum_values"]
)
)

url = url.replace(f"{{{variable_name}}}", used_value)
Expand Down
4 changes: 2 additions & 2 deletions src/datadog_api_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, configuration, pools_size=4, maxsize=4):
key_file=configuration.key_file,
proxy_url=configuration.proxy,
proxy_headers=configuration.proxy_headers,
**addition_pool_args
**addition_pool_args,
)
else:
self.pool_manager = urllib3.PoolManager(
Expand All @@ -100,7 +100,7 @@ def __init__(self, configuration, pools_size=4, maxsize=4):
ca_certs=configuration.ssl_ca_cert,
cert_file=configuration.cert_file,
key_file=configuration.key_file,
**addition_pool_args
**addition_pool_args,
)

def request(
Expand Down
10 changes: 6 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,19 @@ def freezed_time(default_cassette_name, record_mode, vcr):
freeze_file = pathlib.Path(vcr._path).with_suffix(".frozen")
if not freeze_file.exists():
msg = (
"Time file '{}' not found: create one setting `RECORD=true` or "
"ignore it using `RECORD=none`".format(freeze_file)
"Time file '{}' not found: create one setting `RECORD=true` or " "ignore it using `RECORD=none`".format(
freeze_file
)
)
raise RuntimeError(msg)
with freeze_file.open("r") as f:
freeze_at = f.readline().strip()

if not pathlib.Path(vcr._path).exists():
msg = (
"Cassette '{}' not found: create one setting `RECORD=true` or "
"ignore it using `RECORD=none`".format(vcr._path)
"Cassette '{}' not found: create one setting `RECORD=true` or " "ignore it using `RECORD=none`".format(
vcr._path
)
)
raise RuntimeError(msg)

Expand Down

0 comments on commit 9b91d1a

Please sign in to comment.