Skip to content

Commit

Permalink
✅ make linters happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerteltier committed Jan 15, 2024
1 parent 4952601 commit 5210849
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Install requirements
run: pip install -r pip-requirements.txt
- name: Install Pylint + stuff required for checking the tests and setup.py
run: pip install -c pip-constraints.txt html5lib pylint pylint-pytest pytest time-machine trove-classifiers
run: pip install -c pip-constraints.txt html5lib pylint pylint-pytest pytest setuptools time-machine trove-classifiers
- name: Run Pylint
run: pylint -r y -d fixme .
env:
Expand Down
2 changes: 1 addition & 1 deletion an_website/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
if sys.flags.dev_mode:
tracemalloc.start()
with contextlib.suppress(ValueError):
sys.activate_stack_trampoline("perf") # pylint: disable=no-member
sys.activate_stack_trampoline("perf")

if __name__ == "__main__":
sys.exit(main())
2 changes: 1 addition & 1 deletion an_website/backdoor/backdoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def load_session(self) -> dict[str, Any]:
value.decode("BRAILLE"),
)
if self.apm_client:
self.apm_client.capture_exception()
self.apm_client.capture_exception() # type: ignore[no-untyped-call]
else:
session = {
"__builtins__": __builtins__,
Expand Down
5 changes: 1 addition & 4 deletions an_website/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@
from ecs_logging import StdlibFormatter
from elastic_enterprise_search import AppSearch # type: ignore[import-untyped]
from elastic_transport import ObjectApiResponse
from elasticapm.contrib.tornado import ( # type: ignore[import-untyped]
ElasticAPM,
)
from elasticapm.contrib.tornado import ElasticAPM
from elasticsearch import AsyncElasticsearch, NotFoundError
from redis.asyncio import (
BlockingConnectionPool,
Expand Down Expand Up @@ -1236,7 +1234,6 @@ def main( # noqa: C901 # pragma: no cover
asyncio.set_event_loop(loop)

if sys.version_info >= (3, 13) and not loop.get_task_factory():
# pylint: disable=no-member
loop.set_task_factory(asyncio.eager_task_factory)

if perf8 and "PERF8" in os.environ:
Expand Down
6 changes: 3 additions & 3 deletions an_website/quotes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from typing import Any, Final, Literal, cast
from urllib.parse import urlencode

import elasticapm # type: ignore[import-untyped]
import elasticapm
import orjson as json
from redis.asyncio import Redis
from tornado.httpclient import AsyncHTTPClient
Expand Down Expand Up @@ -500,7 +500,7 @@ async def update_cache_periodically(app: Application) -> None:
await asyncio.wait_for(EVENT_REDIS.wait(), 5)
redis: Redis[str] = cast("Redis[str]", app.settings.get("REDIS"))
prefix: str = app.settings.get("REDIS_PREFIX", NAME).removesuffix("-dev")
apm: None | elasticapm.Client # type: ignore[no-any-unimported]
apm: None | elasticapm.Client
if EVENT_REDIS.is_set(): # pylint: disable=too-many-nested-blocks
await parse_list_of_quote_data(
await redis.get(f"{prefix}:cached-quote-data:wrongquotes"), # type: ignore[arg-type] # noqa: B950
Expand Down Expand Up @@ -536,7 +536,7 @@ async def update_cache_periodically(app: Application) -> None:
"CLIENT"
)
if apm:
apm.capture_exception()
apm.capture_exception() # type: ignore[no-untyped-call]
else:
LOGGER.info("Updated quotes cache successfully")
LOGGER.info(
Expand Down
2 changes: 1 addition & 1 deletion an_website/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def search(self) -> list[dict[str, float | str]]:
except Exception: # pylint: disable=broad-except
LOGGER.exception("App Search request failed")
if self.apm_client:
self.apm_client.capture_exception()
self.apm_client.capture_exception() # type: ignore[no-untyped-call]
if result is not None:
return result
return self.search_old(query)
Expand Down
8 changes: 4 additions & 4 deletions an_website/utils/base_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from urllib.parse import SplitResult, urlsplit, urlunsplit
from zoneinfo import ZoneInfo

import elasticapm # type: ignore[import-untyped]
import elasticapm
import html2text
import orjson as json
import regex
Expand Down Expand Up @@ -155,9 +155,9 @@ def _finish(
return super().finish()

@property
def apm_client(self) -> None | elasticapm.Client: # type: ignore[no-any-unimported]
def apm_client(self) -> None | elasticapm.Client:
"""Get the APM client from the settings."""
return self.settings.get("ELASTIC_APM", {}).get("CLIENT")
return self.settings.get("ELASTIC_APM", {}).get("CLIENT") # type: ignore[no-any-return]

@property
def apm_enabled(self) -> bool:
Expand Down Expand Up @@ -563,7 +563,7 @@ async def get_time(self) -> datetime:
except (ApiError, TransportError):
LOGGER.exception("Elasticsearch request failed")
if self.apm_client:
self.apm_client.capture_exception()
self.apm_client.capture_exception() # type: ignore[no-untyped-call]
else:
if geoip and "timezone" in geoip:
tz = ZoneInfo(geoip["timezone"])
Expand Down
2 changes: 1 addition & 1 deletion an_website/utils/static_file_from_traversable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import sys
from collections.abc import Awaitable, Iterable
from importlib.abc import Traversable
from importlib.abc import Traversable # pylint: disable=no-name-in-module
from pathlib import Path

from tornado import httputil, iostream
Expand Down
2 changes: 1 addition & 1 deletion an_website/utils/static_file_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import sys
from collections.abc import Awaitable, Mapping
from functools import cache
from importlib.abc import Traversable
from importlib.abc import Traversable # pylint: disable=no-name-in-module
from pathlib import Path
from typing import Any, Final, cast

Expand Down
4 changes: 2 additions & 2 deletions an_website/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
)
from urllib.parse import SplitResult, parse_qsl, urlencode, urlsplit, urlunsplit

import elasticapm # type: ignore[import-untyped]
import elasticapm
import regex
from blake3 import blake3
from elastic_transport import ApiError, TransportError
Expand Down Expand Up @@ -251,7 +251,7 @@ def anonymize_ip(
ansi_replace.__doc__ = "Remove ANSI escape sequences from a string."


def apm_anonymization_processor( # type: ignore[no-any-unimported]
def apm_anonymization_processor(
client: elasticapm.Client, # pylint: disable=unused-argument
event: dict[str, Any],
) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions scripts/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

import os
import subprocess
import subprocess # nosec: B404
import sys
from datetime import datetime, timezone
from os.path import dirname, join, normpath
Expand All @@ -44,7 +44,7 @@ def main(*args: str) -> int | str:
"GIT_COMMITTER_DATE": date_str,
}
env.update(os.environ)
result = subprocess.run(
result = subprocess.run( # nosec: B603, B607
["git", "commit", "-m", message], env=env, check=False
)

Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import socket
from collections.abc import Awaitable, Callable, MutableMapping, Set
from datetime import datetime, timezone
from os import environ
from os import environ # pylint: disable=ungrouped-imports
from pathlib import Path
from typing import Any, cast
from urllib.parse import parse_qsl, urlsplit
Expand Down
2 changes: 1 addition & 1 deletion tests/test_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_token_v0() -> None:
b"\x00\x00\x00\x00\x00*", # 42
)
assert (
token == "ABQAAAAAACoAAAAAZAAAAAAAVuGjEJjux2P8zah"
token == "ABQAAAAAACoAAAAAZAAAAAAAVuGjEJjux2P8zah" # nosec: B105
"9SjQGkxCWn9Iaszr/qJJHJSMWoRPoVjQKa6/jKFWPdBehSL0K"
)

Expand Down

0 comments on commit 5210849

Please sign in to comment.