Skip to content

Commit

Permalink
📝 replace requests import to niquests in docstrings
Browse files Browse the repository at this point in the history
Also move constants DEFAUL_POOL* to _constant.py
  • Loading branch information
Ousret committed Sep 20, 2023
1 parent c4e675e commit 065900d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
7 changes: 3 additions & 4 deletions src/niquests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ def check_compatibility(urllib3_version, charset_normalizer_version) -> None:
# Check urllib3 for compatibility.
major, minor, patch = urllib3_version # noqa: F811
major, minor, patch = int(major), int(minor), int(patch)
# urllib3 >= 1.21.1
assert major >= 1
if major == 1:
assert minor >= 21
# urllib3 >= 2.0.9xx
assert major >= 2
assert patch >= 900

# Check charset_normalizer for compatibility.
major, minor, patch = charset_normalizer_version.split(".")[:3]
Expand Down
4 changes: 4 additions & 0 deletions src/niquests/_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
READ_DEFAULT_TIMEOUT: TimeoutType = 30
#: Default timeout (total) assigned for DELETE, PUT, PATCH, and POST.
WRITE_DEFAULT_TIMEOUT: TimeoutType = 120

DEFAULT_POOLBLOCK: bool = False
DEFAULT_POOLSIZE: int = 10
DEFAULT_RETRIES: int = 0
13 changes: 4 additions & 9 deletions src/niquests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from urllib3.util import parse_url
from urllib3.util.retry import Retry

from ._constant import DEFAULT_POOLBLOCK, DEFAULT_POOLSIZE, DEFAULT_RETRIES
from ._typing import CacheLayerAltSvcType, ProxyType, TLSClientCertType, TLSVerifyType
from .auth import _basic_auth_str
from .cookies import extract_cookies_to_jar
Expand Down Expand Up @@ -66,12 +67,6 @@ def SOCKSProxyManager(*args: typing.Any, **kwargs: typing.Any) -> None: # type:
raise InvalidSchema("Missing dependencies for SOCKS support.")


DEFAULT_POOLBLOCK = False
DEFAULT_POOLSIZE = 10
DEFAULT_RETRIES = 0
DEFAULT_POOL_TIMEOUT = None


class BaseAdapter:
"""The Base Transport Adapter"""

Expand Down Expand Up @@ -129,9 +124,9 @@ class HTTPAdapter(BaseAdapter):
Usage::
>>> import requests
>>> s = requests.Session()
>>> a = requests.adapters.HTTPAdapter(max_retries=3)
>>> import niquests
>>> s = niquests.Session()
>>> a = niquests.adapters.HTTPAdapter(max_retries=3)
>>> s.mount('http://', a)
"""

Expand Down
4 changes: 2 additions & 2 deletions src/niquests/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def request(
Usage::
>>> import requests
>>> req = requests.request('GET', 'https://httpbin.org/get')
>>> import niquests
>>> req = niquests.request('GET', 'https://httpbin.org/get')
>>> req
<Response HTTP/2 [200]>
"""
Expand Down
10 changes: 5 additions & 5 deletions src/niquests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class Request:
Usage::
>>> import requests
>>> req = requests.Request('GET', 'https://httpbin.org/get')
>>> import niquests
>>> req = niquests.Request('GET', 'https://httpbin.org/get')
>>> req.prepare()
<PreparedRequest [GET]>
"""
Expand Down Expand Up @@ -219,13 +219,13 @@ class PreparedRequest:
Usage::
>>> import requests
>>> req = requests.Request('GET', 'https://httpbin.org/get')
>>> import niquests
>>> req = niquests.Request('GET', 'https://httpbin.org/get')
>>> r = req.prepare()
>>> r
<PreparedRequest [GET]>
>>> s = requests.Session()
>>> s = niquests.Session()
>>> s.send(r)
<Response HTTP/2 [200]>
"""
Expand Down
6 changes: 3 additions & 3 deletions src/niquests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ class Session:
Basic Usage::
>>> import requests
>>> s = requests.Session()
>>> import niquests
>>> s = niquests.Session()
>>> s.get('https://httpbin.org/get')
<Response HTTP/2 [200]>
Or as a context manager::
>>> with requests.Session() as s:
>>> with niquests.Session() as s:
... s.get('https://httpbin.org/get')
<Response HTTP/2 [200]>
"""
Expand Down
8 changes: 4 additions & 4 deletions src/niquests/status_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
Example::
>>> import requests
>>> requests.codes['temporary_redirect']
>>> import niquests
>>> niquests.codes['temporary_redirect']
307
>>> requests.codes.teapot
>>> niquests.codes.teapot
418
>>> requests.codes['\o/']
>>> niquests.codes['\o/']
200
Some codes have multiple names, and both upper- and lower-case versions of
Expand Down

0 comments on commit 065900d

Please sign in to comment.