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

Upgrade flake8 + pycodestyle #3096

Merged
merged 3 commits into from
Dec 21, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/athenian/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ async def _extract_api_key(self, token: str, request: AthenianWebRequest) -> Tup
return user, await request.sdb.fetch_val(
select([UserAccount.account_id]).where(UserAccount.user_id == user),
)
kms = request.app["kms"] # type: AthenianKMS
kms: AthenianKMS = request.app["kms"]
if kms is None:
raise AuthenticationProblem(
status=HTTPStatus.UNAUTHORIZED,
Expand Down
4 changes: 2 additions & 2 deletions server/athenian/api/controllers/histograms_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ async def calculate_for_set_histograms(filter_checks: FilterChecks):
]
total_group_suites = my_suite_counts.sum()
for suite_size_group_index, suite_size_group in enumerate(lines_group):
group_for_set = (
group_for_set: ForSetCodeChecks = (
for_set.select_pushers_group(pushers_group_index)
.select_repogroup(repos_group_index)
.select_lines(lines_index)
) # type: ForSetCodeChecks
)
if filt.split_by_check_runs:
suite_size = suite_sizes[suite_size_group_index]
group_suites_count_ratio = (
Expand Down
4 changes: 2 additions & 2 deletions server/athenian/api/controllers/metrics_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,15 @@ async def calc_code_bypassing_prs(request: AthenianWebRequest, body: dict) -> we
calculator = make_calculator(
filt.account, meta_ids, request.mdb, request.pdb, request.rdb, request.cache,
)
stats = await calculator.calc_code_metrics_github(
stats: list[CodeStats] = await calculator.calc_code_metrics_github(
FilterCommitsProperty.BYPASSING_PRS,
time_intervals,
[r.unprefixed for r in repos],
with_author,
with_committer,
filt.only_default_branch,
prefixer,
) # type: list[CodeStats]
)
model = [
CodeBypassingPRsMeasurement(
date=(d - tzoffset).date(),
Expand Down
4 changes: 2 additions & 2 deletions server/athenian/api/defer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from asyncio import Event, current_task, ensure_future, gather, shield, sleep
from contextvars import ContextVar
import logging
from typing import Awaitable, Coroutine, List
from typing import Awaitable, Coroutine

from aiohttp import web
import asyncpg
Expand Down Expand Up @@ -47,7 +47,7 @@ def launch_defer(delay: float, name: str, detached: bool = False) -> None:
if launch_event.is_set():
log.warning("launch_defer() called multiple times")
return
transaction_ptr = _defer_transaction.get() # type: List[Transaction]
transaction_ptr: list[Transaction] = _defer_transaction.get()
deferred_count_ptr = _defer_counter.get()
explicit_launch = _defer_explicit.get()
except LookupError:
Expand Down
4 changes: 2 additions & 2 deletions server/athenian/api/experiments/idmatching/make_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def main():
args = parse_args()
bar = tqdm(total=11)
engine = create_engine(args.metadata_db)
mdb = sessionmaker(bind=engine)() # type: Session
mdb: Session = sessionmaker(bind=engine)()
bar.update(1)
engine = create_engine(args.state_db)
sdb = sessionmaker(bind=engine)() # type: Session
sdb: Session = sessionmaker(bind=engine)()
bar.update(1)
meta_id = (
sdb.query(AccountGitHubAccount.id)
Expand Down
2 changes: 1 addition & 1 deletion server/athenian/api/experiments/indexing/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def virtual_indexes(df):
]:
print(f"Building for layer {layer_level}...")
df_level = df.groupby(col).agg({"values": sum}).reset_index()
df_level["values"] = df_level["values"].apply(lambda l: list(set(l)))
df_level["values"] = df_level["values"].apply(lambda lv: list(set(lv)))
df_level = df_level.rename(columns={col: "timestamp"})

layers[layer_level] = layer(df_level)
Expand Down
5 changes: 2 additions & 3 deletions server/athenian/api/models/precomputed/schema_monitor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
from collections import defaultdict
import logging
from typing import List, Optional

import aiohttp
from alembic import script
Expand All @@ -16,7 +15,7 @@ def schedule_pdb_schema_check(
pdb: morcilla.Database,
app: aiohttp.web.Application,
interval: float = 15 * 60,
) -> List[asyncio.Task]:
) -> list[asyncio.Task]:
"""
Execute the precomputed DB schema version check every `interval` seconds.

Expand All @@ -27,7 +26,7 @@ def schedule_pdb_schema_check(
log = logging.getLogger("%s.scheduled_pdb_schema_check" % metadata.__package__)
req_rev = script.ScriptDirectory(str(template.parent)).get_current_head()
sql = MigrationContext.configure(url=str(pdb.url), opts={"as_sql": True})._version.select()
task_box = [None] # type: List[Optional[asyncio.Task]]
task_box: list[asyncio.Task | None] = [None]

async def pdb_schema_check_callback() -> None:
await asyncio.sleep(interval)
Expand Down
6 changes: 3 additions & 3 deletions server/requirements-lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ flake8-comprehensions==3.10.1
flake8-debugger==4.1.2
flake8-docstrings==1.6.0
flake8-pie==0.16.0
flake8-quotes==3.3.1
flake8-quotes==3.3.2
flake8-sfs==0.0.4
flake8-pyproject==1.2.2
flake8==5.0.4
flake8==6.0.0
isort==5.11.3
pycodestyle==2.9.1
pycodestyle==2.10.0
pydocstyle==6.1.1
semgrep==1.2.1
sqlalchemy-stubs==0.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ async def test_deployment_metrics_calculators_smoke(
default_branches,
):
for i in range(2):
calc = metrics_calculator_factory(
1, (6366825,), with_cache=True,
) # type: MetricEntriesCalculator
calc: MetricEntriesCalculator = metrics_calculator_factory(1, (6366825,), with_cache=True)
if i == 1:
calc._mdb = None
calc._rdb = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def gen_dummy_df(dt: datetime) -> pd.DataFrame:


async def test_load_store_precomputed_done_smoke(pdb, pr_samples, done_prs_facts_loader, prefixer):
samples = pr_samples(200) # type: Sequence[PullRequestFacts]
samples: Sequence[PullRequestFacts] = pr_samples(200)
for i in range(1, 6):
# merged but unreleased
kwargs = dict(**samples[-i])
Expand Down
2 changes: 1 addition & 1 deletion server/tests/internal/miners/jira/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async def test_fetch_released_prs_release_settings_events(
done_prs_facts_loader,
prefixer,
):
samples = pr_samples(12) # type: Sequence[PullRequestFacts]
samples: Sequence[PullRequestFacts] = pr_samples(12)
names = ["one", "two", "three"]
settings = ReleaseSettings(
{
Expand Down