-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Election Day: Add type annotation for public vote json.
TYPE: Feature LINK: OGC-1588
- Loading branch information
Showing
7 changed files
with
146 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,6 @@ install_requires = | |
polib | ||
psycopg2 | ||
purl | ||
pydantic | ||
pycurl<7.45.3 | ||
pyparsing | ||
pyquery | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Contains types used in the public API | ||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from onegov.ballot.types import BallotType | ||
from onegov.ballot.types import DomainOfInfluence | ||
from onegov.core.types import JSONObject | ||
from typing import Literal | ||
from typing import TypedDict | ||
|
||
class ProgressJson(TypedDict): | ||
counted: int | ||
total: int | ||
|
||
class TitleJson(TypedDict, total=False): | ||
de_CH: str | ||
fr_CH: str | ||
it_CH: str | ||
rm_CH: str | ||
|
||
class VoteResultsJson(TypedDict): | ||
answer: str | None | ||
nays_percentage: float | None | ||
yeas_percentage: float | None | ||
|
||
class BallotTotalResultJson(TypedDict): | ||
counted: bool | ||
accepted: bool | ||
eligible_voters: int | ||
invalid: int | ||
cast_ballots: int | ||
turnout: float | ||
empty: int | ||
yeas: int | ||
nays: int | ||
yeas_percentage: float | ||
nays_percentage: float | ||
|
||
class BallotEntityResultJson(BallotTotalResultJson): | ||
id: int | ||
name: str | ||
district: str | ||
|
||
class BallotResultJson(TypedDict): | ||
total: BallotTotalResultJson | ||
entities: list[BallotEntityResultJson] | ||
|
||
class BallotJson(TypedDict): | ||
type: BallotType | ||
title: TitleJson | ||
progress: ProgressJson | ||
results: BallotResultJson | ||
|
||
class DataJson(TypedDict): | ||
json: str | ||
csv: str | ||
|
||
class VoteJson(TypedDict): | ||
completed: bool | ||
date: str | ||
domain: DomainOfInfluence | ||
last_modified: str | ||
progress: ProgressJson | ||
related_link: str | None | ||
title: TitleJson | ||
type: Literal['vote'] | ||
results: VoteResultsJson | ||
ballots: list[BallotJson] | ||
url: str | ||
embed: JSONObject # deprecated | ||
media: JSONObject # deprecated | ||
data: DataJson |
Oops, something went wrong.