Skip to content

Commit cc8cf7b

Browse files
authored
Hide the library implementation (#483)
1 parent 8f8ff9c commit cc8cf7b

File tree

12 files changed

+13543
-1127
lines changed

12 files changed

+13543
-1127
lines changed

CHANGES/483.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hide the library implementation details, make the exposed public list very clean.

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,9 @@ max-line-length = 88
2424
# warn_redundant_casts = True
2525
# warn_unused_ignores = True
2626

27+
[mypy-idna]
28+
ignore_missing_imports = true
29+
2730
[mypy-pytest]
2831
ignore_missing_imports = true
32+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
NO_EXTENSIONS = True
1717

1818

19-
extensions = [Extension("yarl._quoting", ["yarl/_quoting.c"])]
19+
extensions = [Extension("yarl._quoting_c", ["yarl/_quoting_c.c"])]
2020
# extra_compile_args=["-g"],
2121
# extra_link_args=["-g"],
2222

tests/test_cached_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from yarl import cached_property
3+
from yarl._url import cached_property
44

55

66
def test_reify():

tests/test_quoting.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
import pytest
22

3-
from yarl.quoting import _PyQuoter, _PyUnquoter, _Quoter, _Unquoter
3+
from yarl._quoting import NO_EXTENSIONS
44

5+
from yarl._quoting_py import _Quoter as _PyQuoter, _Unquoter as _PyUnquoter
56

6-
@pytest.fixture(params=[_PyQuoter, _Quoter], ids=["py_quoter", "c_quoter"])
7-
def quoter(request):
8-
return request.param
97

8+
if not NO_EXTENSIONS:
9+
from yarl._quoting_c import _Quoter as _CQuoter, _Unquoter as _CUnquoter
1010

11-
@pytest.fixture(params=[_PyUnquoter, _Unquoter], ids=["py_unquoter", "c_unquoter"])
12-
def unquoter(request):
13-
return request.param
11+
@pytest.fixture(params=[_PyQuoter, _CQuoter], ids=["py_quoter", "c_quoter"])
12+
def quoter(request):
13+
return request.param
14+
15+
@pytest.fixture(params=[_PyUnquoter, _CUnquoter], ids=["py_unquoter", "c_unquoter"])
16+
def unquoter(request):
17+
return request.param
18+
19+
20+
else:
21+
22+
@pytest.fixture(params=[_PyQuoter], ids=["py_quoter"])
23+
def quoter(request):
24+
return request.param
25+
26+
@pytest.fixture(params=[_PyUnquoter], ids=["py_unquoter"])
27+
def unquoter(request):
28+
return request.param
1429

1530

1631
def hexescape(char):
@@ -336,15 +351,15 @@ def test_quote_protected(quoter):
336351
assert s == "/path%2Fto/three"
337352

338353

339-
def test_quote_fastpath_safe():
354+
def test_quote_fastpath_safe(quoter):
340355
s1 = "/path/to"
341-
s2 = _Quoter(safe="/")(s1)
356+
s2 = quoter(safe="/")(s1)
342357
assert s1 is s2
343358

344359

345-
def test_quote_fastpath_pct():
360+
def test_quote_fastpath_pct(quoter):
346361
s1 = "abc%A0"
347-
s2 = _Quoter()(s1)
362+
s2 = quoter()(s1)
348363
assert s1 is s2
349364

350365

0 commit comments

Comments
 (0)