Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typing to URL #1084

Merged
merged 33 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fdff60
Add typing to URL
bdraco Sep 2, 2024
8576fb0
changelog
bdraco Sep 2, 2024
086a550
py3.8
bdraco Sep 2, 2024
0fb8bad
Merge branch 'master' into typing
bdraco Sep 2, 2024
10b65f3
Update CHANGES/1084.contrib.rst
bdraco Sep 2, 2024
39c5596
feature as well
bdraco Sep 2, 2024
394d1ba
Merge remote-tracking branch 'origin/typing' into typing
bdraco Sep 2, 2024
857a9cd
copy exclude from aiohttp
bdraco Sep 2, 2024
20ae93d
Merge branch 'master' into typing
bdraco Sep 2, 2024
5e9996d
comments, preen
bdraco Sep 2, 2024
0aa1802
Merge remote-tracking branch 'origin/master' into typing
bdraco Sep 2, 2024
40c71a0
Merge remote-tracking branch 'origin/master' into typing
bdraco Sep 2, 2024
f5d5097
Merge remote-tracking branch 'origin/typing' into typing
bdraco Sep 2, 2024
3f1eb2b
Merge branch 'master' into typing
webknjaz Sep 3, 2024
46633ba
Merge branch 'master' into typing
bdraco Sep 3, 2024
041ea65
Update .coveragerc
bdraco Sep 3, 2024
cc17104
drop pyi
bdraco Sep 3, 2024
d070738
drop pyi since everything is typed now
bdraco Sep 3, 2024
92f98f7
add more types
bdraco Sep 3, 2024
5bb533c
add more types
bdraco Sep 3, 2024
2cb091e
de-dupe
bdraco Sep 3, 2024
78bab1b
de-dupe
bdraco Sep 3, 2024
61d9545
adjust for py3.8
bdraco Sep 3, 2024
1645452
lint
bdraco Sep 3, 2024
db3750a
Update .coveragerc
bdraco Sep 3, 2024
0af0733
keep helpers_c
bdraco Sep 3, 2024
521ba15
Update yarl/_url.py
bdraco Sep 3, 2024
5d1b7a2
Merge branch 'master' into typing
bdraco Sep 3, 2024
b0e4e1c
type dunder compares to object
bdraco Sep 3, 2024
c6d37d9
Update yarl/_url.py
bdraco Sep 3, 2024
2aef0e7
Iterator
bdraco Sep 3, 2024
915ab95
remove hint
bdraco Sep 3, 2024
24768b8
temp lower
bdraco Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source =
*/Lib/site-packages/yarl

[report]
fail_under = 98.97
fail_under = 98.95
skip_covered = true
skip_empty = true
show_missing = true
Expand Down
1 change: 1 addition & 0 deletions CHANGES/1084.contrib.rst
webknjaz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Covered the :class:`~yarl.URL` object with types -- by :user:`bdraco`.
1 change: 1 addition & 0 deletions CHANGES/1084.feature.rst
2 changes: 1 addition & 1 deletion tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_inheritance():
with pytest.raises(TypeError) as ctx:

class MyURL(URL): # type: ignore[misc]
class MyURL(URL):
Dismissed Show dismissed Hide dismissed
pass

assert (
Expand Down
131 changes: 0 additions & 131 deletions yarl/__init__.pyi

This file was deleted.

7 changes: 6 additions & 1 deletion yarl/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
from typing import TYPE_CHECKING

__all__ = ("cached_property",)

Expand All @@ -10,7 +11,11 @@


# isort: off
if not NO_EXTENSIONS: # pragma: no branch
if TYPE_CHECKING:
from ._helpers_py import cached_property as cached_property_py

cached_property = cached_property_py
elif not NO_EXTENSIONS: # pragma: no branch
try:
from ._helpers_c import cached_property as cached_property_c # type: ignore[attr-defined, unused-ignore] # noqa: E501

Expand Down
6 changes: 0 additions & 6 deletions yarl/_helpers_c.pyi
bdraco marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

4 changes: 2 additions & 2 deletions yarl/_quoting_c.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class _Quoter:
qs: bool = ...,
requote: bool = ...
) -> None: ...
def __call__(self, val: Optional[str] = ...) -> Optional[str]: ...
def __call__(self, val: str = ...) -> str: ...

class _Unquoter:
def __init__(
self, *, ignore: str = ..., unsafe: str = ..., qs: bool = ...
) -> None: ...
def __call__(self, val: Optional[str] = ...) -> Optional[str]: ...
def __call__(self, val: str = ...) -> str: ...
6 changes: 3 additions & 3 deletions yarl/_quoting_py.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import codecs
import re
from string import ascii_letters, ascii_lowercase, digits
from typing import Optional, cast
from typing import cast

BASCII_LOWERCASE = ascii_lowercase.encode("ascii")
BPCT_ALLOWED = {f"%{i:02X}".encode("ascii") for i in range(256)}
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(
self._qs = qs
self._requote = requote

def __call__(self, val: Optional[str]) -> Optional[str]:
def __call__(self, val: str) -> str:
if val is None:
return None
if not isinstance(val, str):
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, *, ignore: str = "", unsafe: str = "", qs: bool = False) -> N
self._quoter = _Quoter()
self._qs_quoter = _Quoter(qs=True)

def __call__(self, val: Optional[str]) -> Optional[str]:
def __call__(self, val: str) -> str:
if val is None:
return None
if not isinstance(val, str):
Expand Down
Loading
Loading