Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
thesadru committed Mar 3, 2024
1 parent 9408c83 commit f367e51
Show file tree
Hide file tree
Showing 25 changed files with 37 additions and 11 deletions.
1 change: 1 addition & 0 deletions arkprts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Arknights python wrapper."""

from . import errors, models
from .assets import *
from .auth import *
Expand Down
1 change: 1 addition & 0 deletions arkprts/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry-point."""

import argparse
import asyncio
import logging
Expand Down
1 change: 1 addition & 0 deletions arkprts/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Assets clients."""

from .base import *
from .bundle import *
from .git import *
1 change: 1 addition & 0 deletions arkprts/assets/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry-point."""

import argparse
import asyncio
import logging
Expand Down
1 change: 1 addition & 0 deletions arkprts/assets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Getting assets either requires a unity bundle extractor or a 3rd party git repository.
Image assets are often universal. Game data akways needs to be downloaded for each language.
"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions arkprts/assets/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Downloads assets directly from arknights servers.
Unfortunately assets are stored as unity files, so they need to be extracted.
"""

from __future__ import annotations

import asyncio
Expand Down
5 changes: 3 additions & 2 deletions arkprts/assets/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Has to use two separate repositories,
a game data repository with all languages and an image resource repository with only one language.
"""

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -78,7 +79,7 @@ async def download_github_tarball(

async with aiohttp.ClientSession(auto_decompress=False) as session, session.get(url) as response:
response.raise_for_status()
with destination.open("wb") as file:
with destination.open("wb") as file: # noqa: ASYNC101 # would need another dependency
async for chunk in response.content.iter_any():
file.write(chunk)

Expand All @@ -98,7 +99,7 @@ def decompress_tarball(path: PathLike, destination: PathLike, *, allow: str = "*
member.name = member.name[len(top_directory + "/") :]
members.append(member)

tar.extractall(destination, members=members)
tar.extractall(destination, members=members) # noqa: S202 # type: ignore

return top_directory

Expand Down
5 changes: 4 additions & 1 deletion arkprts/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@
Single sessions are for getting personal data, but disallow concurrent requests.
Multiple sessions are for getting public data and allow concurrent requests.
"""

from __future__ import annotations

import abc
import asyncio
import base64
import contextlib
import dataclasses
import hashlib
import hmac
Expand Down Expand Up @@ -848,7 +850,8 @@ async def _load_upcoming_session(self, server: netn.ArknightsServer) -> AuthSess
warnings.warn(f"Failed to load cached auth: {e}")
# remove faulty auth from cache file
data = list(self._load_cache())
data.remove(auth)
with contextlib.suppress(ValueError):
data.remove(auth)
self._save_cache(data)

return None
Expand Down
1 change: 1 addition & 0 deletions arkprts/automation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Automation client. Potentially bannable."""

from __future__ import annotations

import base64
Expand Down
1 change: 1 addition & 0 deletions arkprts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
>>> client = arkprts.AutomationClient(auth=auth)
>>> await client.account_sync_data()
"""

from __future__ import annotations

import base64
Expand Down
1 change: 1 addition & 0 deletions arkprts/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Arkprts errors."""

from __future__ import annotations

import json
Expand Down
1 change: 1 addition & 0 deletions arkprts/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Models used by arkprts."""

from .base import BaseModel
from .battle import *
from .data import *
Expand Down
1 change: 1 addition & 0 deletions arkprts/models/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Modified pydantic base model."""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions arkprts/models/battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Any field description prefixed with IDK means it's just a guess.
"""

import datetime
import typing

Expand Down
1 change: 1 addition & 0 deletions arkprts/models/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Any field description prefixed with IDK means it's just a guess.
"""

import datetime
import typing

Expand Down
1 change: 1 addition & 0 deletions arkprts/models/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Any field description prefixed with IDK means it's just a guess.
"""

import typing

import pydantic
Expand Down
3 changes: 2 additions & 1 deletion arkprts/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| pkgAd | https://play.google.com/store/apps/details?id=com.YoStarEN.Arknights | Google play store apk |
| pkgIOS | https://apps.apple.com/us/app/id1464872022?mt=8 | IOS store apk |
"""

from __future__ import annotations

import asyncio
Expand All @@ -39,7 +40,7 @@
"NetworkSession",
]

LOGGER: logging.Logger = logging.getLogger("arkprts.auth")
LOGGER: logging.Logger = logging.getLogger("arkprts.network")

# these are in no way official slugs, just my own naming

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration file for the Sphinx documentation builder."""

from __future__ import annotations

import typing
Expand Down
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox file."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -75,7 +76,7 @@ def reformat(session: nox.Session) -> None:
"""Reformat this project's modules to fit the standard style."""
install_requirements(session, "reformat")
session.run("python", "-m", "black", *GENERAL_TARGETS, *verbose_args())
session.run("python", "-m", "ruff", "--fix-only", "--fixable", "ALL", *GENERAL_TARGETS, *verbose_args())
session.run("python", "-m", "ruff", "check", "--fix-only", "--fixable", "ALL", *GENERAL_TARGETS, *verbose_args())

session.log("sort-all")
LOGGER.disabled = True
Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "arkprts"
requires-python = ">=3.9"
version = "0.3.5"
version = "0.3.6"
dynamic = [
"dependencies",
"description",
Expand Down Expand Up @@ -41,9 +41,10 @@ sort = "cover"

[tool.ruff]
target-version = "py38"
select = ["ALL"]
# 120 from black and then a bit
line-length = 130
[tool.ruff.lint]
select = ["ALL"]
# A: Shadowing built-in
# ARG: Unused function argument (duck-typing)
# EM: String literal in exception
Expand Down Expand Up @@ -113,7 +114,7 @@ ignore = [
# B007: Unused loop variable
unfixable = ["F401", "F841", "B007"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# F40: import (unused imports)
"**/__init__.py" = ["F40"]
# T201: use of print
Expand All @@ -126,8 +127,8 @@ unfixable = ["F401", "F841", "B007"]
"docs/conf.py" = ["INP001"]
"dev-requirements/setup.py" = ["INP001"]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="arkprts",
version="0.3.5",
version="0.3.6",
description="Arknights python wrapper.",
url="https://github.com/thesadru/arkprts",
packages=find_packages(exclude=["tests", "tests.*"]),
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pytest configuration."""

import asyncio
import typing
import warnings
Expand Down
1 change: 1 addition & 0 deletions tests/test_assets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test game assets."""

import arkprts


Expand Down
1 change: 1 addition & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test authentication."""

import asyncio
import collections
import os
Expand Down
1 change: 1 addition & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test arkprts client."""

import typing

import arkprts
Expand Down

0 comments on commit f367e51

Please sign in to comment.