Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Galarzaa90 committed Oct 31, 2024
1 parent 6dbfec3 commit 609aa01
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ An API to parse Tibia.com content into object oriented data.

No fetching is done by this module, you must provide the html content.



[![PyPI](https://img.shields.io/pypi/v/tibia.py.svg)](https://pypi.python.org/pypi/tibia.py/)
![GitHub commits since latest release (branch)](https://img.shields.io/github/commits-since/Galarzaa90/tibia.py/latest/main)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tibia.py.svg)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ ignore = [
"ANN401", # Dynamically typed expressions ({name}) are disallowed in `other`
"PLR0913", # Too many arguments in function definition
"PLR2004", # Magic value used in comparison, consider replacing `{number}` with a constant variable
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
]

[tool.ruff.lint.per-file-ignores]
Expand Down
8 changes: 8 additions & 0 deletions tests/tests_bazaar.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
FILE_BAZAAR_HISTORY = "characterBazaar/bazaarHistory.txt"
FILE_AUCTION_FINISHED = "auction/auctionFinished.txt"
FILE_AUCTION_UPGRADED_ITEMS = "auction/auctionWithUpgradedItems.txt"
FILE_AUCTION_FRAGMENT_PROGRESS = "auction/auctionWithFragmentProgress.txt"
FILE_AUCTION_NOT_FOUND = "auction/auctionNotFound.txt"


Expand Down Expand Up @@ -198,6 +199,13 @@ def test_auction_parser_from_content_with_upgraded_items(self):

self.assertEqual(2, auction.displayed_items[2].tier)

def test_auction_parser_from_content_with_fragment_progress(self):
auction = AuctionParser.from_content(self.load_resource(FILE_AUCTION_UPGRADED_ITEMS))

self.assertIsNotNone(auction)

self.assertEqual(2, auction.displayed_items[2].tier)

def test_auction_parser_from_content_not_found(self):
auction = AuctionParser.from_content(self.load_resource(FILE_AUCTION_NOT_FOUND))

Expand Down
2 changes: 1 addition & 1 deletion tibiapy/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __str__(self):
return self.name.lower()

@classmethod
def validate(cls, v: Any):
def validate(cls, v: Any) -> Self:
e = try_enum(cls, v)
if e is None:
raise EnumValueError(cls, v)
Expand Down
8 changes: 4 additions & 4 deletions tibiapy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InvalidContentError(TibiapyError):
"""

def __init__(self, message: str, original=None):
def __init__(self, message: str, original: Exception = None):
super().__init__(message)
self.original = original

Expand All @@ -58,7 +58,7 @@ class NetworkError(TibiapyError):
"""

def __init__(self, message, original=None, fetching_time=0):
def __init__(self, message: str, original: Exception = None, fetching_time: float = 0.0):
super().__init__(message)
self.original = original
self.fetching_time = fetching_time
Expand Down Expand Up @@ -95,11 +95,11 @@ def __init__(self, enum: type[Enum], value: Any) -> None:
)

@property
def names(self):
def names(self) -> str:
"""The valid names for the enum."""
return ", ".join(e.name for e in self.enum)

@property
def values(self):
def values(self) -> str:
"""The valid values for the enum."""
return ", ".join(str(e.value) for e in self.enum)
1 change: 1 addition & 0 deletions tibiapy/models/fansite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Models for supported and promoted fansites."""
from typing import Optional

from tibiapy.models import BaseModel
Expand Down
2 changes: 1 addition & 1 deletion tibiapy/parsers/fansite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

"""Module containing the parser for supported and promoted fansites."""
import bs4

from tibiapy import InvalidContentError
Expand Down

0 comments on commit 609aa01

Please sign in to comment.