Skip to content

Commit 3413b21

Browse files
committed
more ruff fixes
1 parent b5aaae0 commit 3413b21

15 files changed

Lines changed: 44 additions & 67 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ select = [
112112
"T20", # flake8-print
113113
"TC", # refurb
114114
"TID", # flake8-tidy-imports
115-
"UP", # pyupgrade,
115+
"UP", # pyupgrade
116116
"YTT", # flake8-2020
117117
]
118118
ignore = [
@@ -133,7 +133,6 @@ max-line-length = 120
133133
[tool.ruff.lint.pydocstyle]
134134
convention = "google"
135135

136-
137136
[tool.ruff.lint.pep8-naming]
138137
extend-ignore-names = ["assert*"]
139138

@@ -158,3 +157,6 @@ exclude_lines = [
158157
"raise NotImplementedError",
159158
"if TYPE_CHECKING:"
160159
]
160+
161+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
162+
"typing.Self".msg = "Use typing_extensions.Self instead."

tests/models/test_book.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from polyfactory.factories.pydantic_factory import ModelFactory
55

6-
from tibiawikisql.models import Book, Item, ItemStoreOffer
6+
from tibiawikisql.models import Book, Item
77
from tibiawikisql.schema import BookTable, ItemAttributeTable, ItemSoundTable, ItemStoreOfferTable, ItemTable
88

99

tests/models/test_npc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sqlite3
33
import unittest
44

5-
from tibiawikisql.models import Npc, NpcDestination, NpcOffer
5+
from tibiawikisql.models import Npc
66
from tibiawikisql.schema import ItemTable, NpcBuyingTable, NpcDestinationTable, NpcJobTable, NpcRaceTable, \
77
NpcSellingTable, NpcSpellTable, \
88
NpcTable, \

tibiawikisql/generation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def progress_bar(
168168
iterable,
169169
length,
170170
label,
171-
True, # noqa: FBT003
172-
True, # noqa: FBT003
173-
True, # noqa: FBT003
171+
True,
172+
True,
173+
True,
174174
item_show_func,
175175
"█",
176176
"░",

tibiawikisql/models/imbuement.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import contextlib
2-
import sqlite3
32
from sqlite3 import Connection, Cursor, IntegrityError
4-
from sqlite3 import Connection, Cursor
53
from typing import Any
64

75
from pydantic import BaseModel, Field
8-
from pypika import Parameter, Query, Table
6+
from pypika import Parameter, Query
97
from typing_extensions import Self
108

119
from tibiawikisql.api import WikiEntry

tibiawikisql/models/item.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from sqlite3 import Connection, Cursor
2-
from typing import Any, Self
2+
from typing import Any
33

44
import pydantic
55
from pydantic import BaseModel, Field
66
from pypika import Parameter, Query, Table
7+
from typing_extensions import Self
78

89
from tibiawikisql.api import WikiEntry
910
from tibiawikisql.models.base import RowModel, WithImage, WithStatus, WithVersion

tibiawikisql/models/npc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import contextlib
22
import sqlite3
33
from sqlite3 import Connection, Cursor
4-
from typing import Any, Self
4+
from typing import Any
55

66
from pydantic import BaseModel, Field
77
from pypika import Parameter, Query, Table
8+
from typing_extensions import Self
89

910
from tibiawikisql.api import WikiEntry
1011
from tibiawikisql.models.base import RowModel, WithImage, WithStatus, WithVersion

tibiawikisql/models/outfit.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import contextlib
2-
import sqlite3
32
from sqlite3 import Connection, Cursor, IntegrityError
4-
from sqlite3 import Connection, Cursor
53
from typing import Any
64

7-
import pydantic
85
from pydantic import BaseModel, Field
96
from pypika import Parameter, Query, Table
107
from typing_extensions import Self

tibiawikisql/models/spell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from sqlite3 import Connection, Cursor
2-
from typing import Any, Self
2+
from typing import Any
33

44
from pydantic import BaseModel, Field
5+
from typing_extensions import Self
56

67
from tibiawikisql.api import WikiEntry
78
from tibiawikisql.models.base import RowModel, WithImage, WithStatus, WithVersion

tibiawikisql/parsers/creature.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,13 @@ def match(k):
105105
return loot
106106

107107

108-
def parse_abilities(value):
108+
def parse_abilities(value: str) -> list[dict[str, str]]:
109109
"""Parse the abilities of a creature.
110110
111-
Parameters
112-
----------
113-
value: :class:`str`
114-
A string containing the creature's abilities definition.
111+
Args:
112+
value: A string containing the creature's abilities definition.
115113
116-
Returns
117-
-------
118-
:class:`list` of :class:`dict`
114+
Returns:
119115
A list of dictionaries with the ability data.
120116
121117
"""
@@ -173,26 +169,21 @@ def parse_abilities(value):
173169
return abilities
174170

175171

176-
def parse_monster_walks(value):
172+
def parse_monster_walks(value: str) -> str | None:
177173
"""Match the values against a regex to filter typos or bad data on the wiki.
178174
179175
Element names followed by any character that is not a comma will be considered unknown and will not be returned.
180176
181-
Examples
182-
--------
177+
Examples:
183178
- ``Poison?, fire`` will return ``fire``.
184-
- ``Poison?, fire.`` will return neither.
179+
- ``Poison?, fire?.`` will return neither.
185180
- ``Poison, earth, fire?, [[ice]]`` will return ``poison,earth``.
186181
- ``No``, ``--``, ``>``, or ``None`` will return ``None``.
187182
188-
Parameters
189-
----------
190-
value: :class:`str`
191-
The string containing possible field types.
183+
Args:
184+
value: The string containing possible field types.
192185
193-
Returns
194-
-------
195-
:class:`str`, optional
186+
Returns:
196187
A list of field types, separated by commas.
197188
198189
"""

0 commit comments

Comments
 (0)