Skip to content

Commit

Permalink
Updated Requirements + Admin (#32)
Browse files Browse the repository at this point in the history
- Updated requirements
- Formatted code
- Added Makefile
  • Loading branch information
joeyagreco authored Nov 27, 2023
1 parent 7cb2089 commit 7d87225
Show file tree
Hide file tree
Showing 26 changed files with 83 additions and 96 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/formatting-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black==23.3.0
make deps
- name: Check Formatting
run: |
black --config pyproject.toml --check --diff .
- name: Install autoflake
run: pip install autoflake==2.1.1

- name: Check for Unused Imports
run: autoflake --config pyproject.toml --check .
make fmt-check
36 changes: 14 additions & 22 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,27 @@ name: Main Build

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
make deps
- name: Run unit tests
run: |
make test
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- N/A
- Updated package requirements

## [1.7.0]

Expand Down
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: deps
deps:
@python3 -m pip install -r requirements.dev.txt
@python3 -m pip install -r requirements.txt

.PHONY: fmt
fmt:
@black --config=pyproject.toml .
@autoflake --config=pyproject.toml .
@isort .

.PHONY: fmt-check
fmt-check:
@black --config=pyproject.toml --check .
@autoflake --config=pyproject.toml --check .
@isort --check-only .

.PHONY: test
test:
@pytest test/

.PHONY: up-reqs
up-reqs:
@pipreqs --force
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Please make sure to update tests as appropriate.
## Development

_Run these commands from the root folder_
- Format Code: `./main fmt`
- Run Unit Tests: `./main test`
- Generate Coverage Report: `./main cov`
- Install Dependencies: `make deps`
- Format Code: `make fmt`
- Run Unit Tests: `make test`

## License

Expand Down
4 changes: 1 addition & 3 deletions example/draft_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from sleeper.api import DraftAPIClient
from sleeper.enum import Sport
from sleeper.model import Draft
from sleeper.model import DraftPick
from sleeper.model import PlayerDraftPick
from sleeper.model import Draft, DraftPick, PlayerDraftPick

if __name__ == "__main__":
# get all drafts that a user was in for a particular year
Expand Down
8 changes: 4 additions & 4 deletions example/league_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from sleeper.enum import Sport
from sleeper.model import (
League,
Roster,
User,
Matchup,
PlayoffMatchup,
Transaction,
TradedPick,
Roster,
SportState,
TradedPick,
Transaction,
User,
)

if __name__ == "__main__":
Expand Down
21 changes: 0 additions & 21 deletions main.bat

This file was deleted.

3 changes: 2 additions & 1 deletion requirements.format.txt → requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
black==23.3.0
autoflake==2.1.1
isort==5.12.0
isort==5.12.0
pytest==7.4.3
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
requests~=2.28.2
configparser~=5.3.0
setuptools~=66.1.1
Pillow~=9.4.0
Pillow==10.1.0
Requests==2.31.0
setuptools==69.0.2
2 changes: 1 addition & 1 deletion sleeper/api/unofficial/UPlayerAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

from sleeper.api.SleeperAPIClient import SleeperAPIClient
from sleeper.enum import SeasonType, PlayerPosition
from sleeper.enum import PlayerPosition, SeasonType
from sleeper.enum.Sport import Sport
from sleeper.model.PlayerStats import PlayerStats

Expand Down
2 changes: 1 addition & 1 deletion sleeper/enum/ModelEnum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import unique, Enum
from enum import Enum, unique

from sleeper.util.CustomLogger import CustomLogger

Expand Down
2 changes: 1 addition & 1 deletion sleeper/enum/PlayerPosition.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from abc import abstractmethod
from enum import unique, Enum
from enum import Enum, unique

from sleeper.enum.Sport import Sport

Expand Down
2 changes: 1 addition & 1 deletion sleeper/enum/PlayerStatus.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from abc import abstractmethod
from enum import unique, Enum
from enum import Enum, unique

from sleeper.enum.Sport import Sport

Expand Down
4 changes: 2 additions & 2 deletions sleeper/enum/RosterPosition.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import annotations

from abc import abstractmethod
from enum import unique, Enum
from enum import Enum, unique

from sleeper.enum.Sport import Sport
from sleeper.enum.nfl.NFLRosterPosition import NFLRosterPosition
from sleeper.enum.Sport import Sport


@unique
Expand Down
2 changes: 1 addition & 1 deletion sleeper/enum/SportTeam.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from abc import abstractmethod
from enum import unique, Enum
from enum import Enum, unique

from sleeper.enum.Sport import Sport

Expand Down
2 changes: 1 addition & 1 deletion sleeper/model/Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import datetime
from dataclasses import dataclass

from sleeper.enum import SportTeam, Sport
from sleeper.enum import Sport, SportTeam
from sleeper.enum.SeasonStatus import SeasonStatus


Expand Down
2 changes: 1 addition & 1 deletion sleeper/model/PlayerStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import datetime
from dataclasses import dataclass

from sleeper.enum import SportTeam, Sport, SeasonType
from sleeper.enum import SeasonType, Sport, SportTeam
from sleeper.enum.Category import Category
from sleeper.enum.Company import Company
from sleeper.model import Player
Expand Down
2 changes: 1 addition & 1 deletion test/test_api/test_AvatarAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import os
import tempfile
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from requests import HTTPError

from sleeper.api.AvatarAPIClient import AvatarAPIClient
from sleeper.exception.SleeperAPIException import SleeperAPIException
from test.helper.helper_classes import MockResponse


class TestAvatarAPIClient(unittest.TestCase):
Expand Down
8 changes: 4 additions & 4 deletions test/test_api/test_DraftAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from requests import HTTPError
Expand All @@ -7,19 +8,18 @@
from sleeper.enum.DraftStatus import DraftStatus
from sleeper.enum.DraftType import DraftType
from sleeper.enum.InjuryStatus import InjuryStatus
from sleeper.enum.ScoringType import ScoringType
from sleeper.enum.SeasonType import SeasonType
from sleeper.enum.Sport import Sport
from sleeper.enum.nfl.NFLPlayerStatus import NFLPlayerStatus
from sleeper.enum.nfl.NFLPosition import NFLPosition
from sleeper.enum.nfl.NFLTeam import NFLTeam
from sleeper.enum.ScoringType import ScoringType
from sleeper.enum.SeasonType import SeasonType
from sleeper.enum.Sport import Sport
from sleeper.model.Draft import Draft
from sleeper.model.DraftMetadata import DraftMetadata
from sleeper.model.DraftPick import DraftPick
from sleeper.model.DraftSettings import DraftSettings
from sleeper.model.PlayerDraftPick import PlayerDraftPick
from sleeper.model.PlayerDraftPickMetadata import PlayerDraftPickMetadata
from test.helper.helper_classes import MockResponse


class TestDraftAPIClient(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions test/test_api/test_LeagueAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import datetime
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from requests import HTTPError

from sleeper.api import LeagueAPIClient
from sleeper.enum.nfl.NFLRosterPosition import NFLRosterPosition
from sleeper.enum.PlayoffRoundType import PlayoffRoundType
from sleeper.enum.SeasonStatus import SeasonStatus
from sleeper.enum.SeasonType import SeasonType
from sleeper.enum.Sport import Sport
from sleeper.enum.TransactionStatus import TransactionStatus
from sleeper.enum.TransactionType import TransactionType
from sleeper.enum.nfl.NFLRosterPosition import NFLRosterPosition
from sleeper.model.FAABTransaction import FAABTransaction
from sleeper.model.FromPlayoffMatchup import FromPlayoffMatchup
from sleeper.model.League import League
Expand All @@ -26,7 +27,6 @@
from sleeper.model.Transaction import Transaction
from sleeper.model.TransactionSettings import TransactionSettings
from sleeper.model.User import User
from test.helper.helper_classes import MockResponse


class TestLeagueAPIClient(unittest.TestCase):
Expand Down
8 changes: 4 additions & 4 deletions test/test_api/test_PlayerAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import datetime
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from requests import HTTPError

from sleeper.api.PlayerAPIClient import PlayerAPIClient
from sleeper.enum.InjuryStatus import InjuryStatus
from sleeper.enum.PracticeParticipation import PracticeParticipation
from sleeper.enum.Sport import Sport
from sleeper.enum.TrendType import TrendType
from sleeper.enum.nfl.NFLPlayerStatus import NFLPlayerStatus
from sleeper.enum.nfl.NFLPosition import NFLPosition
from sleeper.enum.nfl.NFLTeam import NFLTeam
from sleeper.enum.PracticeParticipation import PracticeParticipation
from sleeper.enum.Sport import Sport
from sleeper.enum.TrendType import TrendType
from sleeper.model.Player import Player
from sleeper.model.PlayerTrend import PlayerTrend
from test.helper.helper_classes import MockResponse


class TestPlayerAPIClient(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion test/test_api/test_UserAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from requests import HTTPError

from sleeper.api.UserAPIClient import UserAPIClient
from sleeper.model.User import User
from test.helper.helper_classes import MockResponse


class TestUserAPIClient(unittest.TestCase):
Expand Down
8 changes: 4 additions & 4 deletions test/test_api/test_unofficial/test_UPlayerAPIClient.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import tempfile
import unittest
from test.helper.helper_classes import MockResponse
from unittest import mock

from sleeper.api.unofficial import UPlayerAPIClient
from sleeper.enum import SeasonType, Company, Category
from sleeper.enum import Category, Company, SeasonType
from sleeper.enum.nfl import NFLPosition, NFLTeam
from sleeper.enum.Sport import Sport
from sleeper.enum.nfl import NFLTeam, NFLPosition
from sleeper.model import PlayerStats, Player
from sleeper.model import Player, PlayerStats
from sleeper.model.nfl import NFLStats
from test.helper.helper_classes import MockResponse


class TestUPlayerAPIClient(unittest.TestCase):
Expand Down
Loading

0 comments on commit 7d87225

Please sign in to comment.