Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update black precommit #22521

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ repos:
- license-templates/LICENSE.txt
- --fuzzy-match-generates-todo
- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.1.0
hooks:
- id: black
args: [--config=./pyproject.toml]
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/databricks/hooks/databricks_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def my_after_func(retry_state):
else:
self.retry_args = dict(
stop=stop_after_attempt(self.retry_limit),
wait=wait_exponential(min=self.retry_delay, max=(2 ** retry_limit)),
wait=wait_exponential(min=self.retry_delay, max=(2**retry_limit)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that’s an interesting change of style.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In psf/black#538 (where the change was made), it mentions that PEP 8 advises to only use whitespace to help make operator precedence more clear (** has a high precedence), and to not use it otherwise.

retry=retry_if_exception(self._retryable_error),
after=my_after_func,
)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/elasticsearch/log/es_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def es_read(self, log_id: str, offset: str, metadata: dict) -> list:

def emit(self, record):
if self.handler:
record.offset = int(time() * (10 ** 9))
record.offset = int(time() * (10**9))
self.handler.emit(record)

def set_context(self, ti: TaskInstance) -> None:
Expand Down
4 changes: 2 additions & 2 deletions airflow/providers/google/cloud/hooks/mlengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def _poll_with_exponential_delay(request, execute_num_retries, max_n, is_done_fu
log.info('Operation is done: %s', response)
return response

time.sleep((2 ** i) + (random.randint(0, 1000) / 1000))
time.sleep((2**i) + (random.randint(0, 1000) / 1000))
except HttpError as e:
if e.resp.status != 429:
log.info('Something went wrong. Not retrying: %s', format(e))
raise
else:
time.sleep((2 ** i) + (random.randint(0, 1000) / 1000))
time.sleep((2**i) + (random.randint(0, 1000) / 1000))

raise ValueError(f'Connection could not be established after {max_n} retries.')

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# under the License.
[tool.black]
line-length = 110
target-version = ['py36', 'py37', 'py38', 'py39']
target-version = ['py37', 'py38', 'py39', 'py310']
skip-string-normalization = true
2 changes: 1 addition & 1 deletion scripts/in_container/run_resource_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_size(bytes):
Convert Bytes into Gigabytes
1 Gigabytes = 1024*1024*1024 = 1073741824 bytes
"""
factor = 1024 ** 3
factor = 1024**3
value_gb = bytes / factor
return value_gb

Expand Down
30 changes: 12 additions & 18 deletions tests/providers/google/cloud/hooks/test_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,12 @@ def test_update_productset_explicit_name_different_from_constructed(self, get_co
err = ctx.value
# self.assertIn("The required parameter 'project_id' is missing", str(err))
assert err
assert (
ERR_DIFF_NAMES.format(
explicit_name=explicit_ps_name,
constructed_name=template_ps_name,
label="ProductSet",
id_label="productset_id",
)
in str(err)
)
assert ERR_DIFF_NAMES.format(
explicit_name=explicit_ps_name,
constructed_name=template_ps_name,
label="ProductSet",
id_label="productset_id",
) in str(err)
update_product_set_method.assert_not_called()

@mock.patch('airflow.providers.google.cloud.hooks.vision.CloudVisionHook.get_conn')
Expand Down Expand Up @@ -652,15 +649,12 @@ def test_update_product_explicit_name_different_from_constructed(self, get_conn)
)
err = ctx.value
assert err
assert (
ERR_DIFF_NAMES.format(
explicit_name=explicit_p_name,
constructed_name=template_p_name,
label="Product",
id_label="product_id",
)
in str(err)
)
assert ERR_DIFF_NAMES.format(
explicit_name=explicit_p_name,
constructed_name=template_p_name,
label="Product",
id_label="product_id",
) in str(err)
update_product_method.assert_not_called()

@mock.patch('airflow.providers.google.cloud.hooks.vision.CloudVisionHook.get_conn')
Expand Down