mirror of
https://github.com/PaiGramTeam/python-genshin-artifact.git
synced 2025-02-02 16:35:26 +00:00
✨ Use Ruff for linting
This commit is contained in:
parent
6c2548f1ac
commit
a0d89f7e1b
15
.pre-commit-config.yaml
Normal file
15
.pre-commit-config.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.8.1
|
||||
hooks:
|
||||
- id: ruff
|
||||
args:
|
||||
- --fix
|
||||
- id: ruff-format
|
||||
ci:
|
||||
autofix_commit_msg: ":art: [pre-commit.ci] Auto format from pre-commit.com hooks"
|
||||
autoupdate_commit_msg: ":arrow_up: [pre-commit.ci] pre-commit autoupdate"
|
@ -44,6 +44,11 @@ bindings = "pyo3"
|
||||
requires = ["maturin>=1.0,<2.0"]
|
||||
build-backend = "maturin"
|
||||
|
||||
[dependency-groups]
|
||||
linting = [
|
||||
'ruff',
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
log_cli = true
|
||||
log_cli_level = "INFO"
|
||||
@ -53,4 +58,23 @@ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
|
||||
[tool.black]
|
||||
include = '\.pyi?$'
|
||||
line-length = 120
|
||||
target-version = ["py38"]
|
||||
target-version = ["py38"]
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.lint]
|
||||
extend-select = [
|
||||
"Q", # flake8-quotes
|
||||
"C90", # complex-structure
|
||||
"I", # isort
|
||||
"F", # pyflakes
|
||||
"B", # flake8-bugbear
|
||||
"C4", # flake8-comprehensions
|
||||
]
|
||||
extend-ignore = [
|
||||
"E721", # using type() instead of isinstance() - we use this in tests
|
||||
]
|
||||
mccabe = { max-complexity = 13 }
|
||||
isort = { known-first-party = ["python_genshin_artifact", "tests"] }
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
from ._python_genshin_artifact import (
|
||||
Artifact,
|
||||
BuffInterface,
|
||||
CalculatorConfig,
|
||||
CharacterInterface,
|
||||
DamageAnalysis,
|
||||
DamageResult,
|
||||
EnemyInterface,
|
||||
SkillInterface,
|
||||
TransformativeDamage,
|
||||
WeaponInterface,
|
||||
gen_artifact_meta_as_json,
|
||||
gen_character_meta_as_json,
|
||||
gen_generate_locale_as_json,
|
||||
gen_weapon_meta_as_json,
|
||||
get_damage_analysis,
|
||||
get_transformative_damage,
|
||||
gen_character_meta_as_json,
|
||||
gen_weapon_meta_as_json,
|
||||
gen_artifact_meta_as_json,
|
||||
gen_generate_locale_as_json,
|
||||
TransformativeDamage,
|
||||
CharacterInterface,
|
||||
WeaponInterface,
|
||||
BuffInterface,
|
||||
Artifact,
|
||||
SkillInterface,
|
||||
EnemyInterface,
|
||||
CalculatorConfig,
|
||||
DamageResult,
|
||||
DamageAnalysis,
|
||||
)
|
||||
|
||||
__all__ = (
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import List, Optional, Tuple, TYPE_CHECKING, Dict, final
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, final
|
||||
|
||||
if sys.version_info < (3, 11):
|
||||
from typing_extensions import Literal
|
||||
|
@ -1,11 +1,11 @@
|
||||
import json
|
||||
from typing import Dict, Tuple, List
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from python_genshin_artifact import (
|
||||
gen_character_meta_as_json,
|
||||
gen_weapon_meta_as_json,
|
||||
gen_artifact_meta_as_json,
|
||||
gen_character_meta_as_json,
|
||||
gen_generate_locale_as_json,
|
||||
gen_weapon_meta_as_json,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
import re
|
||||
from typing import Tuple, List, Optional
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from python_genshin_artifact import Artifact, CharacterInterface, WeaponInterface
|
||||
from python_genshin_artifact.enka.artifacts import artifacts_name_map, equip_type_map
|
||||
from python_genshin_artifact.enka.assets import Assets
|
||||
from python_genshin_artifact.enka.characters import characters_map
|
||||
from python_genshin_artifact.enka.fight import fight_map, to_float
|
||||
from python_genshin_artifact.enka.weapon import weapon_name_map
|
||||
from python_genshin_artifact.error import EnkaParseException
|
||||
from python_genshin_artifact import Artifact, CharacterInterface, WeaponInterface
|
||||
|
||||
assets = Assets()
|
||||
|
||||
@ -75,8 +75,8 @@ def de_equip_list(equip_list: list[dict]) -> Tuple[WeaponInterface, List[Artifac
|
||||
_flat = _equip["flat"]
|
||||
try:
|
||||
artifact_id = int(re.findall(r"\d+", _flat["icon"])[0])
|
||||
except IndexError:
|
||||
raise EnkaParseException(f"artifact_id is not found in {_flat['icon']}")
|
||||
except IndexError as exc:
|
||||
raise EnkaParseException(f"artifact_id is not found in {_flat['icon']}") from exc
|
||||
set_name = artifacts_name_map.get(artifact_id)
|
||||
if set_name is None:
|
||||
raise EnkaParseException(f"artifact_id={artifact_id} is not found in assets")
|
||||
|
@ -1,9 +1,9 @@
|
||||
from python_genshin_artifact import (
|
||||
CalculatorConfig,
|
||||
get_damage_analysis,
|
||||
CharacterInterface,
|
||||
SkillInterface,
|
||||
WeaponInterface,
|
||||
get_damage_analysis,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user