Skip to content

Commit

Permalink
Refactor integer division (#34180)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9571d37)
  • Loading branch information
eumiro authored and ephraimbuddy committed Oct 5, 2023
1 parent 25005a6 commit f502e2a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion airflow/www/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def generate_pages(

output.append(previous_node.format(href_link=page_link, disabled=is_disabled))

mid = int(window / 2)
mid = window // 2
last_page = num_of_pages - 1

if current_page <= mid or num_of_pages < window:
Expand Down
4 changes: 2 additions & 2 deletions dev/stats/calculate_statistics_provider_testing_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Stats:
users_commented: set[str]

def percent_tested(self) -> int:
return int(100.0 * self.tested_issues / self.num_issues)
return 100 * self.tested_issues // self.num_issues

def num_involved_users_who_commented(self) -> int:
return len(self.users_involved.intersection(self.users_commented))
Expand All @@ -87,7 +87,7 @@ def num_commenting_not_involved(self) -> int:
return len(self.users_commented - self.users_involved)

def percent_commented_among_involved(self) -> int:
return int(100.0 * self.num_involved_users_who_commented() / len(self.users_involved))
return 100 * self.num_involved_users_who_commented() // len(self.users_involved)

def __str__(self):
return (
Expand Down
2 changes: 1 addition & 1 deletion scripts/in_container/update_quarantined_test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_history_status(history: TestHistory):
return "Stable"
if all(history.states[0 : num_runs - 1]):
return "Just one more"
if all(history.states[0 : int(num_runs / 2)]):
if all(history.states[0 : num_runs // 2]):
return "Almost there"
return "Flaky"

Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_dagcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_bulk_sync_to_db_half_files(self):
"""Dg code can be bulk written into database."""
example_dags = make_example_dags(example_dags_module)
files = [dag.fileloc for dag in example_dags.values()]
half_files = files[: int(len(files) / 2)]
half_files = files[: len(files) // 2]
with create_session() as session:
DagCode.bulk_sync_to_db(half_files, session=session)
session.commit()
Expand Down
2 changes: 1 addition & 1 deletion tests/www/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def check_generate_pages_html(
assert min(window, total_pages) + extra_links == len(ulist_items)

page_items = ulist_items[2:-2]
mid = int(len(page_items) / 2)
mid = len(page_items) // 2
all_nodes = []
pages = []

Expand Down

0 comments on commit f502e2a

Please sign in to comment.