core-https 2.0.0__py3-none-any.whl → 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
core_https/__init__.py CHANGED
@@ -1,10 +1,23 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ from core_mixins import StrEnum
4
+
3
5
  try:
4
- from enum import StrEnum
6
+ from http import HTTPStatus as _HTTPStatus
5
7
 
6
8
  except ImportError:
7
- from core_mixins.compatibility import StrEnum # type: ignore
9
+ from .utils import HTTPStatus as _HTTPStatus # type: ignore
10
+
11
+
12
+ __all__ = [
13
+ "HTTPStatus",
14
+ "StatusInfo"
15
+ ]
16
+
17
+
18
+ # Type alias that works with both standard library
19
+ # and the custom HTTPStatus...
20
+ HTTPStatus = _HTTPStatus
8
21
 
9
22
 
10
23
  class StatusInfo(StrEnum):
core_https/exceptions.py CHANGED
@@ -8,7 +8,8 @@ HTTP-related errors in a structured and consistent manner. The exception
8
8
  hierarchy is designed to allow for fine-grained error handling while
9
9
  maintaining compatibility with standard HTTP status codes.
10
10
 
11
- Exception Hierarchy:
11
+ Exception Hierarchy::
12
+
12
13
  Exception
13
14
  └── InternalServerError (base for all HTTP errors)
14
15
  ├── ServiceException (handled service errors)
@@ -7,12 +7,6 @@ from typing import Any
7
7
  from typing import Dict
8
8
  from typing import Optional
9
9
 
10
- try:
11
- from typing import Self
12
-
13
- except ImportError:
14
- from typing_extensions import Self
15
-
16
10
  from aiohttp import (
17
11
  ClientResponse,
18
12
  ClientResponseError,
@@ -20,9 +14,10 @@ from aiohttp import (
20
14
  ClientTimeout,
21
15
  TCPConnector,
22
16
  )
17
+ from core_mixins import Self
23
18
 
24
- from .base import IRequester
25
19
  from .base import HTTPMethod
20
+ from .base import IRequester
26
21
 
27
22
 
28
23
  class AioHttpRequester(IRequester):
core_https/tests/base.py CHANGED
@@ -45,10 +45,6 @@ class BaseHttpTestCases(TestCase):
45
45
  the code_mapper attribute, which can be used in test assertions and
46
46
  mock response creation.
47
47
 
48
- Attributes:
49
- code_mapper: Dictionary mapping HTTP status codes (int) to their
50
- corresponding reason phrases (str). Generated from HTTPStatus enum.
51
-
52
48
  Example:
53
49
  Basic usage in test methods::
54
50
 
@@ -85,4 +81,6 @@ class BaseHttpTestCases(TestCase):
85
81
  - HTTPStatus: The enum class providing status code definitions
86
82
  """
87
83
 
84
+ # Dictionary mapping HTTP status codes to their reason phrases.
85
+ # Generated from :class:`HTTPStatus` enum.
88
86
  code_mapper: Dict[int, str] = HTTPStatus.as_dict()
core_https/utils.py CHANGED
@@ -50,12 +50,7 @@ See Also:
50
50
  from enum import Enum
51
51
  from typing import Dict
52
52
 
53
- try:
54
- from typing import Self
55
-
56
- except ImportError:
57
- # For earlier versions...
58
- from typing_extensions import Self
53
+ from core_mixins import Self
59
54
 
60
55
 
61
56
  class HTTPStatus(Enum):
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: core-https
3
+ Version: 2.0.2
4
+ Summary: This project/library contains common elements related to HTTP & API services...
5
+ Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
+ Maintainer: Alejandro Cora González
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
+ Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Requires-Python: >=3.9
25
+ Description-Content-Type: text/x-rst
26
+ License-File: LICENSE
27
+ Requires-Dist: aiohttp<4.0.0,>=3.12.0; python_version >= "3.9"
28
+ Requires-Dist: core-mixins>=2.2.2
29
+ Requires-Dist: requests<3.0.0,>=2.32.3; python_version >= "3.9"
30
+ Requires-Dist: urllib3<3.0.0,>=2.2.3; python_version >= "3.9"
31
+ Provides-Extra: dev
32
+ Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
33
+ Requires-Dist: core-tests>=2.0.2; extra == "dev"
34
+ Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
35
+ Dynamic: license-file
36
+
37
+ core-https
38
+ ===============================================================================
39
+
40
+ This project/library contains common elements related to HTTP...
41
+
42
+ ===============================================================================
43
+
44
+ .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
45
+ :target: https://pypi.org/project/core-https/
46
+ :alt: Python Versions
47
+
48
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
49
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
50
+ :alt: License
51
+
52
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
53
+ :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
54
+ :alt: Pipeline Status
55
+
56
+ .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
57
+ :target: https://readthedocs.org/projects/core-https/
58
+ :alt: Docs Status
59
+
60
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
61
+ :target: https://github.com/PyCQA/bandit
62
+ :alt: Security
63
+
64
+ |
65
+
66
+
67
+ Installation
68
+ ===============================================================================
69
+
70
+ Install from PyPI using pip:
71
+
72
+ .. code-block:: bash
73
+
74
+ pip install core-https
75
+ uv pip install core-https # Or using UV...
76
+
77
+
78
+ Features
79
+ ===============================================================================
80
+
81
+ * **HTTP Status Codes & Methods** - Comprehensive enums with backward compatibility for Python < 3.11, including utility methods for status checking (is_success, is_error, etc.) and method properties (is_safe, is_idempotent, is_cacheable)
82
+ * **Status Classification** - ``StatusInfo`` enum for categorizing HTTP responses as success (1xx-3xx), error (4xx), or failure (5xx)
83
+ * **Exception Hierarchy** - Structured exception classes for handling HTTP errors with automatic status code mapping: ``AuthenticationException`` (401), ``AuthorizationException`` (403), ``RateLimitException`` (429), and ``RetryableException`` for temporary failures
84
+ * **HTTP Requesters** - Abstract interface (``IRequester``) with concrete implementations for multiple HTTP libraries (``requests``, ``urllib3``, ``aiohttp``), supporting connection pooling, timeouts, retries, and backoff strategies
85
+ * **Testing Utilities** - Base test classes and decorators for mocking HTTP requests/responses across different HTTP client libraries
86
+
87
+
88
+ Quick Start
89
+ ===============================================================================
90
+
91
+ Installation
92
+ -------------------------------------------------------------------------------
93
+
94
+ Install the package:
95
+
96
+ .. code-block:: bash
97
+
98
+ pip install core-https
99
+ uv pip install core-https # Or using UV...
100
+ pip install -e ".[dev]" # For development...
101
+
102
+ Setting Up Environment
103
+ -------------------------------------------------------------------------------
104
+
105
+ 1. Install required libraries:
106
+
107
+ .. code-block:: bash
108
+
109
+ pip install --upgrade pip
110
+ pip install virtualenv
111
+
112
+ 2. Create Python virtual environment:
113
+
114
+ .. code-block:: bash
115
+
116
+ virtualenv --python=python3.12 .venv
117
+
118
+ 3. Activate the virtual environment:
119
+
120
+ .. code-block:: bash
121
+
122
+ source .venv/bin/activate
123
+
124
+ Install packages
125
+ -------------------------------------------------------------------------------
126
+
127
+ .. code-block:: bash
128
+
129
+ pip install .
130
+ pip install -e ".[dev]"
131
+
132
+ Check tests and coverage
133
+ -------------------------------------------------------------------------------
134
+
135
+ .. code-block:: shell
136
+
137
+ python manager.py run-tests
138
+ python manager.py run-coverage
139
+
140
+
141
+ Contributing
142
+ ===============================================================================
143
+
144
+ Contributions are welcome! Please:
145
+
146
+ 1. Fork the repository
147
+ 2. Create a feature branch
148
+ 3. Write tests for new functionality
149
+ 4. Ensure all tests pass: ``pytest -n auto``
150
+ 5. Run linting: ``pylint core_https``
151
+ 6. Run security checks: ``bandit -r core_https``
152
+ 7. Submit a pull request
153
+
154
+
155
+ License
156
+ ===============================================================================
157
+
158
+ This project is licensed under the MIT License. See the LICENSE file for details.
159
+
160
+
161
+ Links
162
+ ===============================================================================
163
+
164
+ * **Documentation:** https://core-https.readthedocs.io/en/latest/
165
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-https
166
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-https/-/issues
167
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
168
+ * **PyPI:** https://pypi.org/project/core-https/
169
+
170
+
171
+ Support
172
+ ===============================================================================
173
+
174
+ For questions or support, please open an issue on GitLab or contact the maintainers.
175
+
176
+
177
+ Authors
178
+ ===============================================================================
179
+
180
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -1,20 +1,20 @@
1
- core_https/__init__.py,sha256=lNdKHyUnxy_tg39xOq8MOQ4G-ye_HatCxR7VBcF0Dm4,526
2
- core_https/exceptions.py,sha256=pmL7Xywnb1A84gDim8JwNAP7H9ETk4lHxsEi0oX8SWs,4806
1
+ core_https/__init__.py,sha256=bexOHf-BOGzGueMIhnnwh0ReSnp_tT4x5ZiLGW2IgJE,736
2
+ core_https/exceptions.py,sha256=hK7-YUDGJKChfIG14xNEw3-pVMqg0A-Y9zYRF7OounI,4808
3
3
  core_https/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- core_https/utils.py,sha256=-erGeXbQm27IxaN2r_0ebociWacXxSE1fMGJb1utZBc,12192
4
+ core_https/utils.py,sha256=lOfqIojXc-a_VQGU1YHpJy-0sKZXLMMgYazNxlSU3FI,12098
5
5
  core_https/requesters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- core_https/requesters/aiohttp_.py,sha256=4k05rujkBw6B0Mgdpddz6d7pnXN5g6KOdXPYlA7TX0c,10673
6
+ core_https/requesters/aiohttp_.py,sha256=CJSCmiKRicZAr9PnRdfsb1i6uow6iZEtKvI-ScOgZqU,10608
7
7
  core_https/requesters/base.py,sha256=3TObwxZLtbktf44AJJWry_ihm74NRL6ZsRLarJca1QY,16452
8
8
  core_https/requesters/requests_.py,sha256=K5G71tiYfGe3ryGwItMKzCU9rjgn_4NNy8_j-NoKSw0,3302
9
9
  core_https/requesters/urllib3_.py,sha256=pZq88ka7vM80V1_V8Atfx1-ZpUkve68Fk7AiIaZI8y4,3367
10
10
  core_https/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  core_https/tests/aiohttp_.py,sha256=NChlPeyaAMa7p1OtfuC5yZx2E-XQAXm_NTsFnGZjDQE,9622
12
- core_https/tests/base.py,sha256=ss0JWY9KeN_cBwemlzgGwupws4VjSvIYTY4qHT9a7FI,3491
12
+ core_https/tests/base.py,sha256=Nx_nLR7927F1UShva3YJ5gkqtKQaU6g2rpkO__Ph5qg,3436
13
13
  core_https/tests/decorators.py,sha256=5bGLm4f7clY6DO0QYV1Y17gEzg5Ggzkrkgzd7SSfiHo,12875
14
14
  core_https/tests/requests_.py,sha256=hb48wrNPly3QeDww1Q0_H-qCkQAJ-tdB-0jPO4jemO8,8278
15
15
  core_https/tests/urllib3_.py,sha256=8BzyovKo1kz1tebYw2x5MlExJLcOXin0xMhf_vp4QJA,13237
16
- core_https-2.0.0.dist-info/licenses/LICENSE,sha256=dj8Wz7OWOIOTyLJzaYLn8RFz_W5uYWSGR2xS5lHNAl4,1082
17
- core_https-2.0.0.dist-info/METADATA,sha256=AuPWr-1E4VHv61x0IEUdJjSuMpOulySHxW-Ks3G8wu8,3730
18
- core_https-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- core_https-2.0.0.dist-info/top_level.txt,sha256=Ufm6w6dLS6hyTPwMUXt4O6klJfLyKpkaG6csd2kmaDw,11
20
- core_https-2.0.0.dist-info/RECORD,,
16
+ core_https-2.0.2.dist-info/licenses/LICENSE,sha256=dj8Wz7OWOIOTyLJzaYLn8RFz_W5uYWSGR2xS5lHNAl4,1082
17
+ core_https-2.0.2.dist-info/METADATA,sha256=WbsFCKQBf7VmlN16KNa2keGECwvD5OuCq-A3kTxJ8Jw,6600
18
+ core_https-2.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ core_https-2.0.2.dist-info/top_level.txt,sha256=Ufm6w6dLS6hyTPwMUXt4O6klJfLyKpkaG6csd2kmaDw,11
20
+ core_https-2.0.2.dist-info/RECORD,,
@@ -1,112 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: core-https
3
- Version: 2.0.0
4
- Summary: This project/library contains common elements related to HTTP & API services...
5
- Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
- Maintainer: Alejandro Cora González
7
- License: MIT
8
- Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
- Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
- Project-URL: Documentation, https://core-https.readthedocs.io/en/latest/
11
- Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
12
- Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Development Status :: 5 - Production/Stable
16
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
- Classifier: Topic :: Utilities
18
- Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.9
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Requires-Python: >=3.9
26
- Description-Content-Type: text/x-rst
27
- License-File: LICENSE
28
- Requires-Dist: aiohttp<4.0.0,>=3.12.0; python_version >= "3.9"
29
- Requires-Dist: core-mixins>=2.1.0
30
- Requires-Dist: core-tests>=2.0.1
31
- Requires-Dist: requests<3.0.0,>=2.32.3; python_version >= "3.9"
32
- Requires-Dist: typing-extensions>=4.8.0; python_version >= "3.9" and python_version < "3.11"
33
- Requires-Dist: urllib3<3.0.0,>=2.2.3; python_version >= "3.9"
34
- Provides-Extra: dev
35
- Requires-Dist: core-dev-tools>=1.0.1; extra == "dev"
36
- Requires-Dist: types-requests>=2.32.0.20250602; extra == "dev"
37
- Dynamic: license-file
38
-
39
- core-https
40
- ===============================================================================
41
-
42
- This project/library contains common elements related to HTTP...
43
-
44
- ===============================================================================
45
-
46
- .. image:: https://img.shields.io/pypi/pyversions/core-https.svg
47
- :target: https://pypi.org/project/core-https/
48
- :alt: Python Versions
49
-
50
- .. image:: https://img.shields.io/badge/license-MIT-blue.svg
51
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/blob/main/LICENSE
52
- :alt: License
53
-
54
- .. image:: https://gitlab.com/bytecode-solutions/core/core-https/badges/release/pipeline.svg
55
- :target: https://gitlab.com/bytecode-solutions/core/core-https/-/pipelines
56
- :alt: Pipeline Status
57
-
58
- .. image:: https://readthedocs.org/projects/core-https/badge/?version=latest
59
- :target: https://readthedocs.org/projects/core-https/
60
- :alt: Docs Status
61
-
62
- .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
63
- :target: https://github.com/PyCQA/bandit
64
- :alt: Security
65
-
66
- |
67
-
68
- Execution Environment
69
- ---------------------------------------
70
-
71
- Install libraries
72
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
-
74
- .. code-block:: shell
75
-
76
- pip install --upgrade pip
77
- pip install virtualenv
78
- ..
79
-
80
- Create the Python Virtual Environment.
81
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82
-
83
- .. code-block:: shell
84
-
85
- virtualenv --python={{python-version}} .venv
86
- virtualenv --python=python3.11 .venv
87
- ..
88
-
89
- Activate the Virtual Environment.
90
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
91
-
92
- .. code-block:: shell
93
-
94
- source .venv/bin/activate
95
- ..
96
-
97
- Install required libraries.
98
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
-
100
- .. code-block:: shell
101
-
102
- pip install .
103
- ..
104
-
105
- Check tests and coverage.
106
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107
-
108
- .. code-block:: shell
109
-
110
- python manager.py run-tests
111
- python manager.py run-coverage
112
- ..