Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"

107 changes: 68 additions & 39 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,79 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish

name: Upload Python Package
on:
push:
tags: ["[0-9]+.[0-9]+.[0-9]+*"]

permissions:
contents: write
id-token: write

on: workflow_dispatch
permissions: {}

jobs:
deploy:
runs-on: ubuntu-latest
tests:
uses: ./.github/workflows/tests.yml
permissions:
contents: read

build:
needs: tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v7
with:
python-version: "3.14"
- run: python -m pip install build
- run: python -m build
- name: Check the build version matches the tag
run: test -f "dist/edupage_api-${GITHUB_REF_NAME}-py3-none-any.whl"
- name: Check the tag is on master
run: git merge-base --is-ancestor "$GITHUB_SHA" origin/master
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/edupage-api

permissions:
id-token: write
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/download-artifact@v8
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build pdoc3

- name: Regenerate documentation
run: |
pdoc3 --html edupage_api
rm -rf docs
mv html/edupage_api docs

- name: Commit and push documentation changes
uses: EndBug/add-and-commit@v9
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1

docs:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
add: "docs"
default_author: github_actions
message: "Regenerate documentation"

- name: Build
run: python -m build
- name: Publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1

python-version: "3.14"
- run: python -m pip install -e . pdoc
- run: pdoc edupage_api -o site
- uses: actions/upload-pages-artifact@v5
with:
path: site/

deploy-docs:
needs: [docs, publish]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:
branches: [master]
pull_request:
workflow_call:

permissions:
contents: read


jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.14"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e .
- run: python -m unittest discover -s tests -v

28 changes: 14 additions & 14 deletions edupage_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __exit__(self, exc_type, exc_value, traceback):

def login(
self, username: str, password: str, subdomain: str
) -> Optional[TwoFactorLogin]:
) -> TwoFactorLogin | None:
"""Login while specifying the subdomain to log into.

Args:
Expand All @@ -77,7 +77,7 @@ def login(

return Login(self).login(username, password, subdomain)

def login_auto(self, username: str, password: str) -> Optional[TwoFactorLogin]:
def login_auto(self, username: str, password: str) -> TwoFactorLogin | None:
"""Login using https://portal.edupage.org. If this doesn't work, please use `Edupage.login`.

Args:
Expand All @@ -100,7 +100,7 @@ def logout(self):

LoginSession(self).logout()

def get_students(self) -> Optional[list[EduStudent]]:
def get_students(self) -> list[EduStudent] | None:
"""Get list of all students in your class.

Returns:
Expand All @@ -109,7 +109,7 @@ def get_students(self) -> Optional[list[EduStudent]]:

return People(self).get_students()

def get_all_students(self) -> Optional[list[EduStudentSkeleton]]:
def get_all_students(self) -> list[EduStudentSkeleton] | None:
"""Get list of all students in your school.

Returns:
Expand All @@ -118,7 +118,7 @@ def get_all_students(self) -> Optional[list[EduStudentSkeleton]]:

return People(self).get_all_students()

def get_teachers(self) -> Optional[list[EduTeacher]]:
def get_teachers(self) -> list[EduTeacher] | None:
"""Get list of all teachers in your school.

Returns:
Expand All @@ -127,7 +127,7 @@ def get_teachers(self) -> Optional[list[EduTeacher]]:

return People(self).get_teachers()

def get_classrooms(self) -> Optional[list[Classroom]]:
def get_classrooms(self) -> list[Classroom] | None:
"""Get list of all classrooms in your school.

Returns:
Expand All @@ -136,7 +136,7 @@ def get_classrooms(self) -> Optional[list[Classroom]]:

return Classrooms(self).get_classrooms()

def get_classes(self) -> Optional[list[Class]]:
def get_classes(self) -> list[Class] | None:
"""Get list of all classes in your school.

Returns:
Expand All @@ -145,7 +145,7 @@ def get_classes(self) -> Optional[list[Class]]:

return Classes(self).get_classes()

def get_subjects(self) -> Optional[list[Subject]]:
def get_subjects(self) -> list[Subject] | None:
"""Get list of all subjects in your school.

Returns:
Expand All @@ -155,7 +155,7 @@ def get_subjects(self) -> Optional[list[Subject]]:
return Subjects(self).get_subjects()

def send_message(
self, recipients: Union[list[EduAccount], EduAccount], body: str
self, recipients: list[EduAccount] | EduAccount, body: str
) -> int:
"""Send message.

Expand All @@ -169,7 +169,7 @@ def send_message(

return Messages(self).send_message(recipients, body)

def get_my_timetable(self, date: date) -> Optional[Timetable]:
def get_my_timetable(self, date: date) -> Timetable | None:
"""Get timetable for the logged-in user on a specified date.

Args:
Expand All @@ -181,7 +181,7 @@ def get_my_timetable(self, date: date) -> Optional[Timetable]:

return Timetables(self).get_my_timetable(date)

def get_meals(self, date: date) -> Optional[Meals]:
def get_meals(self, date: date) -> Meals | None:
"""Get lunches.

Args:
Expand Down Expand Up @@ -322,9 +322,9 @@ def get_school_year(self) -> int:

def get_timetable(
self,
target: Union[EduTeacher, EduStudent, Class, Classroom],
target: EduTeacher | EduStudent | Class | Classroom,
date: date,
) -> Optional[Timetable]:
) -> Timetable | None:
"""Get timetable of a teacher, student, class, or classroom for a specific date.

Args:
Expand All @@ -348,7 +348,7 @@ def get_next_ringing_time(self, date_time: datetime) -> RingingTime:
"""
return RingingTimes(self).get_next_ringing_time(date_time)

def switch_to_child(self, child: Union[EduAccount, int]):
def switch_to_child(self, child: EduAccount | int):
"""Switch to an account of a child - can only be used on parent accounts

Args:
Expand Down
10 changes: 5 additions & 5 deletions edupage_api/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class Class:
class_id: int
name: str
short: str
homeroom_teachers: Optional[list[EduTeacher]]
homeroom: Optional[Classroom]
grade: Optional[int]
homeroom_teachers: list[EduTeacher] | None
homeroom: Classroom | None
grade: int | None


class Classes(Module):
@ModuleHelper.logged_in
def get_classes(self) -> Optional[list]:
def get_classes(self) -> list | None:
classes_list = DbiHelper(self.edupage).fetch_class_list()

if classes_list is None:
Expand Down Expand Up @@ -56,7 +56,7 @@ def get_classes(self) -> Optional[list]:

return classes

def get_class(self, class_id: Union[int, str]) -> Optional[Class]:
def get_class(self, class_id: int | str) -> Class | None:
try:
class_id = int(class_id)
except (ValueError, TypeError):
Expand Down
4 changes: 2 additions & 2 deletions edupage_api/classrooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Classroom:

class Classrooms(Module):
@ModuleHelper.logged_in
def get_classrooms(self) -> Optional[list]:
def get_classrooms(self) -> list | None:
classroom_list = DbiHelper(self.edupage).fetch_classroom_list()

if classroom_list is None:
Expand All @@ -36,7 +36,7 @@ def get_classrooms(self) -> Optional[list]:

return classrooms

def get_classroom(self, classroom_id: Union[int, str]) -> Optional[Classroom]:
def get_classroom(self, classroom_id: int | str) -> Classroom | None:
try:
classroom_id = int(classroom_id)
except (ValueError, TypeError):
Expand Down
2 changes: 1 addition & 1 deletion edupage_api/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __decode_data(data: str) -> str:
return RequestData.chromium_base64_decode(data)

@staticmethod
def encode_request_body(request_data: Union[dict, str]) -> str:
def encode_request_body(request_data: dict | str) -> str:
encoded_data = (
ModuleHelper.encode_form_data(request_data)
if type(request_data) == dict
Expand Down
Loading
Loading