Skip to content

Commit 7c5ea65

Browse files
authored
Merge pull request #7 from dylanbowman314/main
Conforms package to new API schema
2 parents 9ca7c00 + 5734d80 commit 7c5ea65

File tree

8 files changed

+297
-125
lines changed

8 files changed

+297
-125
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,50 @@
1313
`qbreader` is a Python wrapper to the qbreader API as well as a general quizbowl library. It provides
1414
both asynchronous and synchronous interfaces to the API along with functionality for representing questions.
1515

16+
## Tossup Example
17+
1618
```py
1719
>>> from qbreader import Sync as qbr # synchronous interface
18-
>>> tossup = qbr.random_tossup()[0]
20+
>>> sync_client = qbr()
21+
>>> tossup = sync_client.random_tossup()[0]
1922
>>> tossup.question
23+
'<b>Tim Peters wrote 19 “guiding principles” of this programming language, which include the maxim “Complex is better than complicated.” The “pandas” library was written for this language. Unicode string values had to be defined with a “u” in version 2 of this language. Libraries in this language include Tkinter, Tensorflow, (*)</b> NumPy (“numb pie”) and SciPy (“sigh pie”). The framework Django was written in this language. This language uses “duck typing.” Variables in this language are often named “spam” and “eggs.” Guido van Rossum invented, for 10 points, what programming language named for a British comedy troupe?'
24+
>>> tossup.question_sanitized
2025
'Tim Peters wrote 19 “guiding principles” of this programming language, which include the maxim “Complex is better than complicated.” The “pandas” library was written for this language. Unicode string values had to be defined with a “u” in version 2 of this language. Libraries in this language include Tkinter, Tensorflow, (*) NumPy (“numb pie”) and SciPy (“sigh pie”). The framework Django was written in this language. This language uses “duck typing.” Variables in this language are often named “spam” and “eggs.” Guido van Rossum invented, for 10 points, what programming language named for a British comedy troupe?'
2126
>>> tossup.answer
27+
'<b><u>Python</u></b>'
28+
>>> tossup.answer_sanitized
2229
'Python'
2330
>>> tossup.category
2431
<Category.SCIENCE: 'Science'>
2532
>>> tossup.subcategory
2633
<Subcategory.OTHER_SCIENCE: 'Other Science'>
2734
>>> tossup.difficulty
2835
<Difficulty.HS_HARD: '4'>
29-
>>> tossup.set
36+
>>> tossup.set.name
3037
'2022 Prison Bowl'
31-
>>> (tossup.packet_number, tossup.question_number)
38+
>>> (tossup.packet.number, tossup.number)
3239
(4, 20)
3340
```
41+
42+
## Bonus Example
43+
44+
```py
45+
>>> bonus = sync_client.random_bonus()[0]
46+
>>> bonus.leadin
47+
'The Curry–Howard isomorphism states that computer programs are directly equivalent to these mathematical constructs, which can be automated using the languages Lean or Rocq (“rock”). For 10 points each:'
48+
>>> bonus.leadin_sanitized
49+
'The Curry-Howard isomorphism states that computer programs are directly equivalent to these mathematical constructs, which can be automated using the languages Lean or Rocq ("rock"). For 10 points each:'
50+
>>> bonus.parts
51+
('Name these mathematical constructs that are used to formally demonstrate the truth of a mathematical statement.', 'According to the Curry–Howard isomorphism, these programming concepts correspond to individual propositions of a proof. One method of “inferring” these things in programming languages like Python is named for the duck test.', 'Haskell Curry also lends his name to “currying,” a common tool in functional programming languages that transforms a function into a sequence of functions each with a smaller value for this property. A description is acceptable.')
52+
>>> bonus.parts_sanitized
53+
('Name these mathematical constructs that are used to formally demonstrate the truth of a mathematical statement.', 'According to the Curry-Howard isomorphism, these programming concepts correspond to individual propositions of a proof. One method of "inferring" these things in programming languages like Python is named for the duck test.', 'Haskell Curry also lends his name to "currying," a common tool in functional programming languages that transforms a function into a sequence of functions each with a smaller value for this property. A description is acceptable.')
54+
>>> bonus.answers
55+
('mathematical <b><u>proof</u>s</b> [or formal <b><u>proof</u></b>s or <b><u>proof</u></b>s of correctness; accept <b><u>proof</u></b> assistant or theorem <b><u>prover</u></b> or Rocq <b><u>prover</u></b>]', 'data <b><u>type</u></b>s [accept <b><u>type</u></b> inference or duck <b><u>typing</u></b>]', '<b><u>arity</u></b> [accept descriptions of the <b><u>number of argument</u></b>s or the <b><u>number of parameter</u></b>s or the <b><u>number of</u> <u>input</u></b>s of a function]')
56+
>>> bonus.answers_sanitized
57+
('mathematical proofs [or formal proofs or proofs of correctness; accept proof assistant or theorem prover or Rocq prover]', 'data types [accept type inference or duck typing]', 'arity [accept descriptions of the number of arguments or the number of parameters or the number of inputs of a function]')
58+
>>> bonus.difficultyModifiers
59+
('e', 'm', 'h')
60+
>>> bonus.values
61+
(10, 10, 10)
62+
```

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "qbreader"
3-
version = "1.0.0-rc.2"
3+
version = "1.0.0-rc.3"
44
description = "Quizbowl library and Python wrapper for the qbreader API"
55
authors = [
66
"Sky \"g3ner1c\" Hong <[email protected]>",
@@ -27,7 +27,7 @@ classifiers = [
2727
]
2828

2929
[tool.poetry.dependencies]
30-
python = "^3.11"
30+
python = "~3.11"
3131
requests = "^2.31.0"
3232
aiohttp = "^3.8.4"
3333

qbreader/asynchronous.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
UnnormalizedCategory,
2020
UnnormalizedDifficulty,
2121
UnnormalizedSubcategory,
22+
Year,
2223
)
2324

2425

@@ -210,8 +211,8 @@ async def random_tossup(
210211
categories: UnnormalizedCategory = None,
211212
subcategories: UnnormalizedSubcategory = None,
212213
number: int = 1,
213-
min_year: int = 2010,
214-
max_year: int = 2023,
214+
min_year: int = Year.MIN_YEAR,
215+
max_year: int = Year.CURRENT_YEAR,
215216
) -> tuple[Tossup, ...]:
216217
"""Get random tossups from the database.
217218
@@ -231,9 +232,9 @@ async def random_tossup(
231232
between categories and subcategories.
232233
number : int, default = 1
233234
The number of tossups to return.
234-
min_year : int, default = 2010
235+
min_year : int, default = Year.MIN_YEAR
235236
The oldest year to search for.
236-
max_year : int, default = 2023
237+
max_year : int, default = Year.CURRENT_YEAR
237238
The most recent year to search for.
238239
239240
Returns
@@ -280,8 +281,8 @@ async def random_bonus(
280281
categories: UnnormalizedCategory = None,
281282
subcategories: UnnormalizedSubcategory = None,
282283
number: int = 1,
283-
min_year: int = 2010,
284-
max_year: int = 2023,
284+
min_year: int = Year.MIN_YEAR,
285+
max_year: int = Year.CURRENT_YEAR,
285286
three_part_bonuses: bool = False,
286287
) -> tuple[Bonus, ...]:
287288
"""Get random bonuses from the database.
@@ -302,9 +303,9 @@ async def random_bonus(
302303
between categories and subcategories.
303304
number : int, default = 1
304305
The number of bonuses to return.
305-
min_year : int, default = 2010
306+
min_year : int, default = Year.MIN_YEAR
306307
The oldest year to search for.
307-
max_year : int, default = 2023
308+
max_year : int, default = Year.CURRENT_YEAR
308309
The most recent year to search for.
309310
three_part_bonuses : bool, default = False
310311
Whether to only return bonuses with 3 parts.

qbreader/synchronous.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
UnnormalizedCategory,
2020
UnnormalizedDifficulty,
2121
UnnormalizedSubcategory,
22+
Year,
2223
)
2324

2425

@@ -175,8 +176,8 @@ def random_tossup(
175176
categories: UnnormalizedCategory = None,
176177
subcategories: UnnormalizedSubcategory = None,
177178
number: int = 1,
178-
min_year: int = 2010,
179-
max_year: int = 2023,
179+
min_year: int = Year.MIN_YEAR,
180+
max_year: int = Year.CURRENT_YEAR,
180181
) -> tuple[Tossup, ...]:
181182
"""Get random tossups from the database.
182183
@@ -196,9 +197,9 @@ def random_tossup(
196197
between categories and subcategories.
197198
number : int, default = 1
198199
The number of tossups to return.
199-
min_year : int, default = 2010
200+
min_year : int, default = Year.MIN_YEAR
200201
The oldest year to search for.
201-
max_year : int, default = 2023
202+
max_year : int, default = Year.CURRENT_YEAR
202203
The most recent year to search for.
203204
204205
Returns
@@ -245,8 +246,8 @@ def random_bonus(
245246
categories: UnnormalizedCategory = None,
246247
subcategories: UnnormalizedSubcategory = None,
247248
number: int = 1,
248-
min_year: int = 2010,
249-
max_year: int = 2023,
249+
min_year: int = Year.MIN_YEAR,
250+
max_year: int = Year.CURRENT_YEAR,
250251
three_part_bonuses: bool = False,
251252
) -> tuple[Bonus, ...]:
252253
"""Get random bonuses from the database.
@@ -267,9 +268,9 @@ def random_bonus(
267268
between categories and subcategories.
268269
number : int, default = 1
269270
The number of bonuses to return.
270-
min_year : int, default = 2010
271+
min_year : int, default = Year.MIN_YEAR
271272
The oldest year to search for.
272-
max_year : int, default = 2023
273+
max_year : int, default = Year.CURRENT_YEAR
273274
The most recent year to search for.
274275
three_part_bonuses : bool, default = False
275276
Whether to only return bonuses with 3 parts.

0 commit comments

Comments
 (0)