diff --git a/arkprts/__init__.py b/arkprts/__init__.py index 8958489..b99c413 100644 --- a/arkprts/__init__.py +++ b/arkprts/__init__.py @@ -1,4 +1,5 @@ """Arknights python wrapper.""" + from . import errors, models from .assets import * from .auth import * diff --git a/arkprts/__main__.py b/arkprts/__main__.py index fe9d1cd..60c28a4 100644 --- a/arkprts/__main__.py +++ b/arkprts/__main__.py @@ -1,4 +1,5 @@ """Entry-point.""" + import argparse import asyncio import logging diff --git a/arkprts/assets/__init__.py b/arkprts/assets/__init__.py index acbe952..b1bbc68 100644 --- a/arkprts/assets/__init__.py +++ b/arkprts/assets/__init__.py @@ -1,4 +1,5 @@ """Assets clients.""" + from .base import * from .bundle import * from .git import * diff --git a/arkprts/assets/__main__.py b/arkprts/assets/__main__.py index 4303e19..7a9b3e7 100644 --- a/arkprts/assets/__main__.py +++ b/arkprts/assets/__main__.py @@ -1,4 +1,5 @@ """Entry-point.""" + import argparse import asyncio import logging diff --git a/arkprts/assets/base.py b/arkprts/assets/base.py index a7f2afa..f77c86d 100644 --- a/arkprts/assets/base.py +++ b/arkprts/assets/base.py @@ -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 diff --git a/arkprts/assets/bundle.py b/arkprts/assets/bundle.py index 74c10c9..76278a0 100644 --- a/arkprts/assets/bundle.py +++ b/arkprts/assets/bundle.py @@ -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 diff --git a/arkprts/assets/git.py b/arkprts/assets/git.py index 5f63fa0..a96c302 100644 --- a/arkprts/assets/git.py +++ b/arkprts/assets/git.py @@ -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 @@ -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) @@ -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 diff --git a/arkprts/auth.py b/arkprts/auth.py index 577a4d6..cafe8e3 100644 --- a/arkprts/auth.py +++ b/arkprts/auth.py @@ -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 @@ -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 diff --git a/arkprts/automation.py b/arkprts/automation.py index 9389df1..e28132c 100644 --- a/arkprts/automation.py +++ b/arkprts/automation.py @@ -1,4 +1,5 @@ """Automation client. Potentially bannable.""" + from __future__ import annotations import base64 diff --git a/arkprts/client.py b/arkprts/client.py index 5c15892..d07b8ad 100644 --- a/arkprts/client.py +++ b/arkprts/client.py @@ -19,6 +19,7 @@ >>> client = arkprts.AutomationClient(auth=auth) >>> await client.account_sync_data() """ + from __future__ import annotations import base64 diff --git a/arkprts/errors.py b/arkprts/errors.py index e981488..dd0adaf 100644 --- a/arkprts/errors.py +++ b/arkprts/errors.py @@ -1,4 +1,5 @@ """Arkprts errors.""" + from __future__ import annotations import json diff --git a/arkprts/models/__init__.py b/arkprts/models/__init__.py index 87ab5ea..1b47fcf 100644 --- a/arkprts/models/__init__.py +++ b/arkprts/models/__init__.py @@ -1,4 +1,5 @@ """Models used by arkprts.""" + from .base import BaseModel from .battle import * from .data import * diff --git a/arkprts/models/base.py b/arkprts/models/base.py index 99ba945..a08e284 100644 --- a/arkprts/models/base.py +++ b/arkprts/models/base.py @@ -1,4 +1,5 @@ """Modified pydantic base model.""" + from __future__ import annotations import collections diff --git a/arkprts/models/battle.py b/arkprts/models/battle.py index 768bade..e1e1a55 100644 --- a/arkprts/models/battle.py +++ b/arkprts/models/battle.py @@ -2,6 +2,7 @@ Any field description prefixed with IDK means it's just a guess. """ + import datetime import typing diff --git a/arkprts/models/data.py b/arkprts/models/data.py index ca0d5d6..91cc956 100644 --- a/arkprts/models/data.py +++ b/arkprts/models/data.py @@ -2,6 +2,7 @@ Any field description prefixed with IDK means it's just a guess. """ + import datetime import typing diff --git a/arkprts/models/social.py b/arkprts/models/social.py index 2c797a6..fdf2d6a 100644 --- a/arkprts/models/social.py +++ b/arkprts/models/social.py @@ -2,6 +2,7 @@ Any field description prefixed with IDK means it's just a guess. """ + import typing import pydantic diff --git a/arkprts/network.py b/arkprts/network.py index cb8284e..f35373c 100644 --- a/arkprts/network.py +++ b/arkprts/network.py @@ -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 @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 3d473ad..1bb406a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ """Configuration file for the Sphinx documentation builder.""" + from __future__ import annotations import typing diff --git a/noxfile.py b/noxfile.py index 8ebdad3..0103bfc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ """Nox file.""" + from __future__ import annotations import logging @@ -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 diff --git a/pyproject.toml b/pyproject.toml index d43d4df..5e0da8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "arkprts" requires-python = ">=3.9" -version = "0.3.5" +version = "0.3.6" dynamic = [ "dependencies", "description", @@ -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 @@ -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 @@ -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" diff --git a/setup.py b/setup.py index 86c7828..f917c28 100644 --- a/setup.py +++ b/setup.py @@ -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.*"]), diff --git a/tests/conftest.py b/tests/conftest.py index bd63ed8..ba4d51d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Pytest configuration.""" + import asyncio import typing import warnings diff --git a/tests/test_assets.py b/tests/test_assets.py index 5d9e550..522bf57 100644 --- a/tests/test_assets.py +++ b/tests/test_assets.py @@ -1,4 +1,5 @@ """Test game assets.""" + import arkprts diff --git a/tests/test_auth.py b/tests/test_auth.py index b4220ad..a1ee926 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -1,4 +1,5 @@ """Test authentication.""" + import asyncio import collections import os diff --git a/tests/test_client.py b/tests/test_client.py index b7e48be..cbf607e 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,4 +1,5 @@ """Test arkprts client.""" + import typing import arkprts