Skip to content

Commit

Permalink
New ItemPage (#74)
Browse files Browse the repository at this point in the history
* Fixed fields in subclasses. Fixes GH-69.

* more type annotations

* items support using a generic ItemPage class

* fix tests to account for new behavior

* tests for types

* run types tests on github actions

* fixed typing issues

* backwards compat for Python 3.7

* more tests; skip_nonitem_fields argument

* fix typing issue

* extract SetItemType

* update fields tutorial

* rename SetItemType to Returns

* typo fix

* item_cls_fields -> skip_nonitem_fields

* added a comment to tox.ini temporary dependency

* deprecate ItemWebPage

* test WebPage + fields

* clean up from-fround-up tutorial

* typo fix

* Apply suggestions from code review

Co-authored-by: Adrián Chaves <[email protected]>
Co-authored-by: Kevin Lloyd Bernal <[email protected]>

* ignore B024 flake8-bugbear warning

* more tests for ItemPage validation

* mention to_item earlier in docs

Co-authored-by: Adrián Chaves <[email protected]>
Co-authored-by: Kevin Lloyd Bernal <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2022
1 parent 944dcd7 commit 8f4c4e5
Show file tree
Hide file tree
Showing 21 changed files with 638 additions and 338 deletions.
5 changes: 4 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ ignore =
D209, # Multi-line docstring closing quotes should be on a separate line
D400, # First line should end with a period
D401, # First line should be in imperative mood
D402 # First line should not be the function's "signature"
D402, # First line should not be the function's "signature"

# see https://github.com/PyCQA/flake8-bugbear/issues/278
B024 # abstract base class without abstract methods

per-file-ignores =
# F401: Ignore "imported but unused" errors in __init__ files, as those
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.10']
tox-job: ["mypy", "docs", "linters"]
tox-job: ["mypy", "docs", "linters", "types"]

steps:
- uses: actions/checkout@v2
Expand Down
20 changes: 10 additions & 10 deletions docs/advanced/additional-requests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Executing a HttpRequest instance
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -351,7 +351,7 @@ method on it.
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -396,7 +396,7 @@ Thus, additional requests inside the Page Object are typically needed for it:
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -485,7 +485,7 @@ list of :class:`~.HttpRequest` to be executed in batch using the
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
default_pagination_limit = 10
Expand Down Expand Up @@ -586,7 +586,7 @@ from the previous subsection named: :ref:`httpclient-get-example`.
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -664,7 +664,7 @@ For this example, let's improve the code snippet from the previous subsection na
@attrs.define
class ProductPage(web_poet.ItemWebPage):
class ProductPage(web_poet.WebPage):
http_client: web_poet.HttpClient
default_pagination_limit = 10
Expand Down Expand Up @@ -835,7 +835,7 @@ This can be set using:
@attrs.define
class SomePage(web_poet.ItemWebPage):
class SomePage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -884,7 +884,7 @@ when creating an :class:`~.HttpClient` instance:
@attrs.define
class SomePage(web_poet.ItemWebPage):
class SomePage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -956,7 +956,7 @@ like the ones above, then it would cause the code to look like:
@attrs.define
class SomePage(web_poet.ItemWebPage):
class SomePage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down Expand Up @@ -985,7 +985,7 @@ This makes the code simpler:
@attrs.define
class SomePage(web_poet.ItemWebPage):
class SomePage(web_poet.WebPage):
http_client: web_poet.HttpClient
async def to_item(self):
Expand Down
Loading

0 comments on commit 8f4c4e5

Please sign in to comment.