Add vulture check (#296)

This commit is contained in:
Erik Vroon
2023-10-07 17:23:33 +02:00
committed by GitHub
parent f4d7aae2ea
commit e67b8ec0fa
11 changed files with 22 additions and 46 deletions

View File

@@ -57,3 +57,7 @@ jobs:
- name: Run ruff
run: pipenv run ruff check .
working-directory: backend
- name: Run vulture
run: ! pipenv run vulture |grep "unused function\|unused class\|unused method"
working-directory: backend

View File

@@ -39,6 +39,7 @@ pytest-asyncio = ">=0.20.3"
pytest-cov = ">=4.0.0"
pytest-xdist = ">=3.2.1"
ruff = ">=0.0.292"
vulture = ">=2.10"
[requires]
python_version = "3.10"

View File

@@ -14,14 +14,6 @@ class Environment(EnumAutoStr):
DEMO = auto()
CI = auto()
def get_env_filepath(self) -> str:
return {
Environment.PRODUCTION: 'prod.env',
Environment.DEVELOPMENT: 'dev.env',
Environment.CI: 'ci.env',
Environment.DEMO: 'demo.env',
}[self]
def get_log_level(self) -> int:
return {
Environment.CI: logging.WARNING,

View File

@@ -6,7 +6,7 @@ from bracket.sql.rounds import get_rounds_for_stage
from bracket.sql.teams import get_teams_with_members
async def get_possible_upcoming_matches_for_teams(
async def todo_get_possible_upcoming_matches_for_teams(
tournament_id: int, stage_id: int, filter_: MatchFilter
) -> list[SuggestedMatch]:
suggestions: list[SuggestedMatch] = []

View File

@@ -10,10 +10,6 @@ class Court(BaseModelORM):
tournament_id: int
class CourtInDB(Court):
id: int
class CourtBody(BaseModelORM):
name: str

View File

@@ -20,11 +20,6 @@ class Match(BaseModelORM):
court_id: int | None
class UpcomingMatch(BaseModel):
team1_id: int
team2_id: int
class MatchWithDetails(Match):
team1: FullTeamWithPlayers
team2: FullTeamWithPlayers
@@ -57,12 +52,6 @@ class MatchCreateBody(BaseModelORM):
court_id: int | None
class MatchToInsert(MatchCreateBody):
created: datetime_utc
team1_score: int = 0
team2_score: int = 0
class MatchFilter(BaseModel):
elo_diff_threshold: int
only_behind_schedule: bool

View File

@@ -21,10 +21,6 @@ class Player(BaseModelORM):
return self.id if self.id is not None else int(self.created.timestamp())
class PlayerInDB(Player):
id: int
class PlayerBody(BaseModelORM):
name: str
active: bool

View File

@@ -33,10 +33,3 @@ class StageActivateBody(BaseModelORM):
class StageCreateBody(BaseModelORM):
type: StageType
class StageToInsert(BaseModelORM):
created: datetime_utc
tournament_id: int
type: StageType
is_active: bool = False

View File

@@ -48,10 +48,6 @@ class SinglePlayerResponse(DataResponse[Player]):
pass
class RoundsResponse(DataResponse[list[Round]]):
pass
class RoundsWithMatchesResponse(DataResponse[list[StageWithRounds]]):
pass
@@ -64,10 +60,6 @@ class SingleMatchResponse(DataResponse[Match]):
pass
class TeamsResponse(DataResponse[list[Team]]):
pass
class TeamsWithPlayersResponse(DataResponse[list[FullTeamWithPlayers]]):
pass

View File

@@ -47,7 +47,7 @@ async def sql_delete_club(club_id: int) -> None:
await database.execute(query=query, values={'club_id': club_id})
async def sql_remove_user_from_club(club_id: int, user_id: int) -> None:
async def todo_sql_remove_user_from_club(club_id: int, user_id: int) -> None:
query = '''
DELETE FROM users_x_clubs
WHERE club_id = :club_id
@@ -66,7 +66,7 @@ async def get_clubs_for_user_id(user_id: int) -> list[Club]:
return [Club.parse_obj(result._mapping) for result in results]
async def get_club_for_user_id(club_id: int, user_id: int) -> Club | None:
async def todo_get_club_for_user_id(club_id: int, user_id: int) -> Club | None:
query = '''
SELECT clubs.* FROM clubs
JOIN users_x_clubs uxc on clubs.id = uxc.club_id

View File

@@ -115,4 +115,17 @@ respect-gitignore = false
show-fixes = true
show-source = true
target-version = "py311"
exclude = [".mypy_cache", ".pytest_cache", "__pycache__"]
exclude = [".mypy_cache", ".pytest_cache", "__pycache__"]
[tool.vulture]
min_confidence = 0
paths = ["."]
ignore_decorators = ["@pytest.*", "@*router*", "@app.*", "@*validator*"]
ignore_names = [
"todo*",
"RestartableUvicornWorker",
"_generate_next_value_",
"downgrade",
"upgrade"
]
sort_by_size = true