qbreader.types module#
Types and classes used by the library.
- class qbreader.types.Tossup(question: str, formatted_answer: str | None, answer: str, category: Category, subcategory: Subcategory, set: str, year: int, packet_number: int, question_number: int, difficulty: Difficulty)#
Bases:
object
Tossup class.
- classmethod from_json(json: dict[str, Any]) Self #
Create a Tossup from a JSON object.
See https://www.qbreader.org/api-docs/schemas#tossups for schema.
- check_answer_sync(givenAnswer: str) AnswerJudgement #
Check whether an answer is correct.
- async check_answer_async(givenAnswer: str, session: ClientSession | None = None) AnswerJudgement #
Asynchronously check whether an answer is correct.
- class qbreader.types.Bonus(leadin: str, parts: Sequence[str], formatted_answers: Sequence[str] | None, answers: Sequence[str], category: Category, subcategory: Subcategory, set: str, year: int, packet_number: int, question_number: int, difficulty: Difficulty)#
Bases:
object
Bonus class.
- classmethod from_json(json: dict[str, Any]) Self #
Create a Bonus from a JSON object.
See https://www.qbreader.org/api-docs/schemas#bonus for schema.
- check_answer_sync(part: int, givenAnswer: str) AnswerJudgement #
Check whether an answer is correct.
- async check_answer_async(part: int, givenAnswer: str, session: ClientSession) AnswerJudgement #
Asynchronously check whether an answer is correct.
- class qbreader.types.Packet(tossups: Sequence[Tossup], bonuses: Sequence[Bonus], number: int | None = None, name: str | None = None, year: int | None = None)#
Bases:
object
Class for packets in sets.
- class qbreader.types.QueryResponse(tossups: Sequence[Tossup], bonuses: Sequence[Bonus], tossups_found: int, bonuses_found: int, query_string: str)#
Bases:
object
Class for responses to
api/query
requests.
- class qbreader.types.AnswerJudgement(directive: Directive, directed_prompt: str | None = None)#
Bases:
object
A judgement given by
api/check-answer
.- classmethod from_json(json: dict[str, Any]) Self #
Create an AnswerJudgement from a JSON object.
See https://www.qbreader.org/api-docs/check-answer#returns for schema.
- classmethod check_answer_sync(answerline: str, givenAnswer: str) Self #
Create an AnswerJudgement given an answerline and an answer.
Original API doc at https://www.qbreader.org/api-docs/check-answer.
- async classmethod check_answer_async(answerline: str, givenAnswer: str, session: ClientSession | None = None) Self #
Asynchronously create an AnswerJudgement given an answerline and an answer.
Original API doc at https://www.qbreader.org/api-docs/check-answer.
- Parameters:
answerline (str) – The answerline to check against. Preferably including the HTML tags <b> and <u>, if they are present.
givenAnswer (str) – The answer to check.
session (aiohttp.ClientSession) – The aiohttp session to use for the request.
- class qbreader.types.Category(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
StrEnum
Question category enum.
- LITERATURE = 'Literature'#
- HISTORY = 'History'#
- SCIENCE = 'Science'#
- FINE_ARTS = 'Fine Arts'#
- RELIGION = 'Religion'#
- MYTHOLOGY = 'Mythology'#
- PHILOSOPHY = 'Philosophy'#
- SOCIAL_SCIENCE = 'Social Science'#
- CURRENT_EVENTS = 'Current Events'#
- GEOGRAPHY = 'Geography'#
- OTHER_ACADEMIC = 'Other Academic'#
- TRASH = 'Trash'#
- class qbreader.types.Subcategory(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
StrEnum
Question subcategory enum.
- LITERATURE = 'Literature'#
- HISTORY = 'History'#
- SCIENCE = 'Science'#
- FINE_ARTS = 'Fine Arts'#
- RELIGION = 'Religion'#
- MYTHOLOGY = 'Mythology'#
- PHILOSOPHY = 'Philosophy'#
- SOCIAL_SCIENCE = 'Social Science'#
- CURRENT_EVENTS = 'Current Events'#
- GEOGRAPHY = 'Geography'#
- OTHER_ACADEMIC = 'Other Academic'#
- TRASH = 'Trash'#
- AMERICAN_LITERATURE = 'American Literature'#
- BRITISH_LITERATURE = 'British Literature'#
- CLASSICAL_LITERATURE = 'Classical Literature'#
- EUROPEAN_LITERATURE = 'European Literature'#
- WORLD_LITERATURE = 'World Literature'#
- OTHER_LITERATURE = 'Other Literature'#
- AMERICAN_HISTORY = 'American History'#
- ANCIENT_HISTORY = 'Ancient History'#
- EUROPEAN_HISTORY = 'European History'#
- WORLD_HISTORY = 'World History'#
- OTHER_HISTORY = 'Other History'#
- BIOLOGY = 'Biology'#
- CHEMISTRY = 'Chemistry'#
- PHYSICS = 'Physics'#
- OTHER_SCIENCE = 'Other Science'#
- VISUAL_FINE_ARTS = 'Visual Fine Arts'#
- AUDITORY_FINE_ARTS = 'Auditory Fine Arts'#
- OTHER_FINE_ARTS = 'Other Fine Arts'#
- class qbreader.types.Difficulty(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
StrEnum
Question difficulty enum.
- UNRATED = '0'#
- MS = '1'#
- HS_EASY = '2'#
- HS_REGS = '3'#
- HS_HARD = '4'#
- HS_NATS = '5'#
- ONE_DOT = '6'#
- TWO_DOT = '7'#
- THREE_DOT = '8'#
- FOUR_DOT = '9'#
- OPEN = '10'#
- class qbreader.types.Directive(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
StrEnum
Directives given by
api/check-answer
.- ACCEPT = 'accept'#
- REJECT = 'reject'#
- PROMPT = 'prompt'#
- qbreader.types.QuestionType#
Type alias for question types.
alias of
Union
[Literal
[‘tossup’, ‘bonus’, ‘all’],Type
[Tossup
],Type
[Bonus
]]
- qbreader.types.SearchType#
Type alias for query search types.
alias of
Literal
[‘question’, ‘answer’, ‘all’]
- qbreader.types.ValidDifficulties#
Type alias for valid difficulties.
alias of
Literal
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘10’]
- qbreader.types.UnnormalizedDifficulty#
Type alias for unnormalized difficulties. Union of
Difficulty
,ValidDifficulties
, andcollections.abc.Iterable
containing either.alias of
Optional
[Union
[Difficulty
,Literal
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘10’],Iterable
[Union
[Difficulty
,Literal
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘10’]]]]]
- qbreader.types.UnnormalizedCategory#
Type alias for unnormalized categories. Union of
Category
,str
, andcollections.abc.Iterable
containing either.alias of
Optional
[Union
[Category
,str
,Iterable
[Union
[Category
,str
]]]]
- qbreader.types.UnnormalizedSubcategory#
Type alias for unnormalized subcategories. Union of
Subcategory
,str
, andcollections.abc.Iterable
containing either.alias of
Optional
[Union
[Subcategory
,str
,Iterable
[Union
[Subcategory
,str
]]]]