Skip to content

Commit

Permalink
Fix old python versions support
Browse files Browse the repository at this point in the history
  • Loading branch information
dimakudosh authored and dimakudosh committed Sep 27, 2021
1 parent 43acfdd commit 0bad043
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ language: python

matrix:
include:
- python: 3.5
- python: 3.6
- python: 3.7
- python: 3.8
- python: 3.9
dist: xenial
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ scripts_are_modules = True
warn_unused_configs = True
disallow_untyped_calls = True
check_untyped_defs = True

[mypy-pytz.*]
ignore_missing_imports = True
10 changes: 6 additions & 4 deletions pydfs_lineup_optimizer/player_pool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import FrozenSet, List, Optional, Set, Union, Iterable, Dict, Literal, DefaultDict
from typing import FrozenSet, List, Optional, Set, Union, Iterable, Dict, DefaultDict
from collections import defaultdict
from itertools import chain
from pydfs_lineup_optimizer.settings import BaseSettings
Expand All @@ -23,8 +23,9 @@ def __init__(
to_value: Optional[float] = None,
positions: Optional[Iterable[str]] = None,
teams: Optional[Iterable[str]] = None,
filter_by: Literal['fppg', 'efficiency', 'salary'] = 'fppg',
filter_by: str = 'fppg',
):
assert filter_by in ('fppg', 'efficiency', 'salary')
self.from_value = from_value
self.to_value = to_value
self.positions = frozenset(positions or [])
Expand Down Expand Up @@ -247,7 +248,6 @@ def unlock_player(self, player: DirtyPlayer):
del self._locked_players[player]

def get_players(self, *players_and_groups: Union[DirtyPlayer, PlayerFilter]) -> List[Player]:
result = []
players, filters = [], []
for item in players_and_groups:
if isinstance(item, BaseFilter):
Expand All @@ -261,11 +261,13 @@ def get_players(self, *players_and_groups: Union[DirtyPlayer, PlayerFilter]) ->
all(player_filter.filter(player, False) for player_filter in filters)
}
if players:
result = []
for player in players:
cleaned_player = self._clean_player(player, allowed_players=allowed_players)
if cleaned_player:
result.append(cleaned_player)
return result
return result
return list(allowed_players) if allowed_players else self.all_players

def add_filters(self, *filters: BaseFilter):
self._player_filters.extend(filters)
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ envlist = mypy,py35-{pulp,mip},py36-{pulp,mip},py37-{pulp,mip},py38-{pulp,mip},p

[travis]
python =
3.5: py35,
3.6: py36,
3.7: py37,
3.8: py38,
3.9: py39, mypy

Expand Down

0 comments on commit 0bad043

Please sign in to comment.