Skip to content

Commit

Permalink
pylint: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Nov 29, 2023
1 parent 561c4ba commit d9623e3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion atciss/app/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
from asgi_correlation_id import CorrelationIdMiddleware, correlation_id
from asgi_correlation_id.middleware import is_valid_uuid4

from sqlalchemy.ext.asyncio import create_async_engine

import alembic.command
import alembic.config
from sqlalchemy.ext.asyncio import create_async_engine

from ..config import settings
from .router import root_api_router
Expand Down
2 changes: 2 additions & 0 deletions atciss/app/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

router = APIRouter()


@router.get("/admin/tasks")
async def get_tasks(
user: Annotated[User, Depends(get_admin)],
) -> list[str]:
return [task for task in dir(ac) if isinstance(getattr(ac, task), celery.Task)]


@router.post("/admin/task/{task}")
async def trigger_task(
task: str,
Expand Down
2 changes: 1 addition & 1 deletion atciss/app/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async def get_admin(token: Annotated[str, Depends(oauth2_scheme)]) -> User:
user = await get_user(token)
payload = jwt.decode(token, settings.SECRET_KEY, algorithms=[ALGORITHM])

if not user or not payload.get('admin'):
if not user or not payload.get("admin"):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Could not validate credentials",
Expand Down
16 changes: 10 additions & 6 deletions atciss/app/tasks/sct.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ...config import settings
from ..views import sct_parser


async def find_airac_zip_url() -> str:
async with AiohttpClient.get() as aiohttp_client:
res = await aiohttp_client.get("http://files.aero-nav.com/EDXX")
Expand All @@ -24,23 +25,26 @@ async def find_airac_zip_url() -> str:
logger.info(f"AIRAC URL: {url}")
return url

raise Exception("No EDMM AIRAC update found")
raise RuntimeError("No EDMM AIRAC update found")


async def fetch_airac_zip(url: str) -> ZipFile:
async with AiohttpClient.get() as aiohttp_client:
async with aiohttp_client.get(url, headers={
"referer": "https://files.aero-nav.com/EDXX/"
}) as res:
async with aiohttp_client.get(
url, headers={"referer": "https://files.aero-nav.com/EDXX/"}
) as res:
zipbytes = await res.read()

return ZipFile(BytesIO(zipbytes))

async def extract_sct_file(zip: ZipFile) -> str | None:
for path in Path(zip).iterdir():

async def extract_sct_file(zipfile: ZipFile) -> str | None:
for path in Path(zipfile).iterdir():
if path.suffix == ".sct":
logger.info(f".sct file: {path.name}")
return path.read_text(encoding="windows-1252")


async def import_sct() -> None:
"""Periodically fetch ECFMP flow measures."""
redis_client = await RedisClient.get()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ disable = [
"C0103", # invalid-name
]
output-format = "colorized"
max-line-length = "100"
max-line-length = "101"
max-locals = 20

[tool.pyright]
Expand Down

0 comments on commit d9623e3

Please sign in to comment.