Skip to content

Commit

Permalink
Update black precommit (#22521)
Browse files Browse the repository at this point in the history
Use latest version of black, drop py36, and add py310.
  • Loading branch information
jedcunningham authored Mar 25, 2022
1 parent 96e880d commit c063fc6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
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)),
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

0 comments on commit c063fc6

Please sign in to comment.