Skip to content

Commit

Permalink
fix naming and annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Jun 1, 2022
1 parent 71bb150 commit bb2a8f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tests/test_page_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import parsel
from web_poet.page_inputs import (
ResponseURL,
RequestURL,
RequestUrl,
ResponseUrl,
HttpRequest,
HttpResponse,
HttpRequestBody,
Expand All @@ -18,7 +18,7 @@
)


@pytest.mark.parametrize("cls", [ResponseURL, RequestURL])
@pytest.mark.parametrize("cls", [RequestUrl, ResponseUrl])
def test_url(cls):
url_value = "https://example.com/category/product?query=123&id=xyz#frag1"

Expand Down
4 changes: 2 additions & 2 deletions web_poet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
HttpRequestBody,
HttpResponseBody,
Meta,
RequestURL,
ResponseURL,
RequestUrl,
ResponseUrl,
)
from .overrides import PageObjectRegistry, consume_modules, OverrideRule

Expand Down
6 changes: 2 additions & 4 deletions web_poet/page_inputs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from .meta import Meta
from .client import HttpClient
from .http import (
ResponseURL,
RequestURL,
HttpRequest,
HttpResponse,
HttpRequestHeaders,
HttpResponseHeaders,
HttpRequestBody,
HttpResponseBody,
RequestURL,
ResponseURL
RequestUrl,
ResponseUrl
)
from .browser import BrowserHtml
12 changes: 6 additions & 6 deletions web_poet/page_inputs/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_AnyStrDict = Dict[AnyStr, Union[AnyStr, List[AnyStr], Tuple[AnyStr, ...]]]


class _URL:
class _Url:
def __init__(self, url: Union[str, yarl.URL]):
self._url = yarl.URL(str(url))

Expand All @@ -37,7 +37,7 @@ def scheme(self) -> str:
return self._url.scheme

@property
def host(self) -> str:
def host(self) -> Optional[str]:
return self._url.host

@property
Expand All @@ -53,12 +53,12 @@ def fragment(self) -> str:
return self._url.fragment


class ResponseURL(_URL):
class ResponseUrl(_Url):
""" URL of the response """
pass


class RequestURL(_URL):
class RequestUrl(_Url):
""" URL of the request """
pass

Expand Down Expand Up @@ -197,7 +197,7 @@ class HttpRequest:
**web-poet** like :class:`~.HttpClient`.
"""

url: RequestURL = attrs.field(converter=RequestURL)
url: RequestUrl = attrs.field(converter=RequestUrl)
method: str = attrs.field(default="GET", kw_only=True)
headers: HttpRequestHeaders = attrs.field(
factory=HttpRequestHeaders, converter=HttpRequestHeaders, kw_only=True
Expand Down Expand Up @@ -230,7 +230,7 @@ class HttpResponse(SelectableMixin):
is auto-detected from headers and body content.
"""

url: ResponseURL = attrs.field(converter=ResponseURL)
url: ResponseUrl = attrs.field(converter=ResponseUrl)
body: HttpResponseBody = attrs.field(converter=HttpResponseBody)
status: Optional[int] = attrs.field(default=None, kw_only=True)
headers: HttpResponseHeaders = attrs.field(factory=HttpResponseHeaders,
Expand Down

0 comments on commit bb2a8f2

Please sign in to comment.