Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +6 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/LICENSE +24 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/METADATA +194 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/RECORD +11 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/WHEEL +5 -0
- .venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/_cmp.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/_compat.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/_config.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/_next_gen.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/exceptions.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/filters.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/attr/__pycache__/validators.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/LICENSE +201 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/METADATA +138 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/RECORD +150 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/WHEEL +6 -0
- .venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/top_level.txt +3 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/LICENSE.txt +22 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/METADATA +193 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/RECORD +52 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/WHEEL +5 -0
- .venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/msgspec/__init__.py +35 -0
- .venv/lib/python3.11/site-packages/msgspec/__init__.pyi +185 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/__init__.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/_json_schema.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/_utils.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/_version.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/inspect.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/json.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/msgpack.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/structs.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/toml.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/__pycache__/yaml.cpython-311.pyc +0 -0
- .venv/lib/python3.11/site-packages/msgspec/_json_schema.py +439 -0
- .venv/lib/python3.11/site-packages/msgspec/_utils.py +319 -0
- .venv/lib/python3.11/site-packages/msgspec/_version.py +21 -0
- .venv/lib/python3.11/site-packages/msgspec/inspect.py +1005 -0
- .venv/lib/python3.11/site-packages/msgspec/json.py +8 -0
- .venv/lib/python3.11/site-packages/msgspec/json.pyi +118 -0
- .venv/lib/python3.11/site-packages/msgspec/msgpack.py +7 -0
- .venv/lib/python3.11/site-packages/msgspec/msgpack.pyi +109 -0
- .venv/lib/python3.11/site-packages/msgspec/py.typed +0 -0
- .venv/lib/python3.11/site-packages/msgspec/structs.py +106 -0
- .venv/lib/python3.11/site-packages/msgspec/structs.pyi +37 -0
.gitattributes
CHANGED
|
@@ -109,3 +109,9 @@ tuning-competition-baseline/.venv/lib/python3.11/site-packages/torch/_inductor/_
|
|
| 109 |
.venv/lib/python3.11/site-packages/pillow.libs/libopenjp2-05423b53.so filter=lfs diff=lfs merge=lfs -text
|
| 110 |
.venv/lib/python3.11/site-packages/pillow.libs/libxcb-b8a56d01.so.1.1.0 filter=lfs diff=lfs merge=lfs -text
|
| 111 |
.venv/lib/python3.11/site-packages/vllm/worker/__pycache__/hpu_model_runner.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
.venv/lib/python3.11/site-packages/pillow.libs/libopenjp2-05423b53.so filter=lfs diff=lfs merge=lfs -text
|
| 110 |
.venv/lib/python3.11/site-packages/pillow.libs/libxcb-b8a56d01.so.1.1.0 filter=lfs diff=lfs merge=lfs -text
|
| 111 |
.venv/lib/python3.11/site-packages/vllm/worker/__pycache__/hpu_model_runner.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 112 |
+
.venv/lib/python3.11/site-packages/torchvision.libs/libwebp.4a54d2c8.so.4 filter=lfs diff=lfs merge=lfs -text
|
| 113 |
+
.venv/lib/python3.11/site-packages/torchvision.libs/libnvjpeg.02b6d700.so.12 filter=lfs diff=lfs merge=lfs -text
|
| 114 |
+
.venv/lib/python3.11/site-packages/torchvision.libs/libcudart.41118559.so.12 filter=lfs diff=lfs merge=lfs -text
|
| 115 |
+
.venv/lib/python3.11/site-packages/pycparser/__pycache__/yacctab.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 116 |
+
.venv/lib/python3.11/site-packages/torchvision.libs/libz.5f199d92.so.1 filter=lfs diff=lfs merge=lfs -text
|
| 117 |
+
.venv/lib/python3.11/site-packages/torchvision.libs/libjpeg.ceea7512.so.62 filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020- Mike Borsetti <mike@borsetti.com>
|
| 4 |
+
|
| 5 |
+
This project includes data from https://github.com/mwgg/Airports Copyright
|
| 6 |
+
(c) 2014 mwgg
|
| 7 |
+
|
| 8 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 9 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 10 |
+
in the Software without restriction, including without limitation the rights
|
| 11 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 12 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 13 |
+
furnished to do so, subject to the following conditions:
|
| 14 |
+
|
| 15 |
+
The above copyright notice and this permission notice shall be included in all
|
| 16 |
+
copies or substantial portions of the Software.
|
| 17 |
+
|
| 18 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 19 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 20 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 21 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 22 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 23 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 24 |
+
SOFTWARE.
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/METADATA
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: airportsdata
|
| 3 |
+
Version: 20241001
|
| 4 |
+
Summary: Extensive database of location and timezone data for nearly every airport and landing strip in the world.
|
| 5 |
+
Author-email: Mike Borsetti <mike+airportsdata@borsetti.com>
|
| 6 |
+
Maintainer-email: Mike Borsetti <mike+airportsdata@borsetti.com>
|
| 7 |
+
License: The MIT License (MIT)
|
| 8 |
+
|
| 9 |
+
Copyright (c) 2020- Mike Borsetti <mike@borsetti.com>
|
| 10 |
+
|
| 11 |
+
This project includes data from https://github.com/mwgg/Airports Copyright
|
| 12 |
+
(c) 2014 mwgg
|
| 13 |
+
|
| 14 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 15 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 16 |
+
in the Software without restriction, including without limitation the rights
|
| 17 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 18 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 19 |
+
furnished to do so, subject to the following conditions:
|
| 20 |
+
|
| 21 |
+
The above copyright notice and this permission notice shall be included in all
|
| 22 |
+
copies or substantial portions of the Software.
|
| 23 |
+
|
| 24 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 25 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 26 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 27 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 28 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 29 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 30 |
+
SOFTWARE.
|
| 31 |
+
|
| 32 |
+
Project-URL: Documentation, https://github.com/mborsetti/airportsdata/blob/main/README.rst
|
| 33 |
+
Project-URL: Repository, https://github.com/mborsetti/airportsdata/
|
| 34 |
+
Project-URL: Database (csv), https://github.com/mborsetti/airportsdata/blob/main/airportsdata/airports.csv
|
| 35 |
+
Project-URL: Changelog, https://github.com/mborsetti/airportsdata/blob/main/CHANGELOG.rst
|
| 36 |
+
Project-URL: Issues, https://github.com/mborsetti/airportsdata/issues
|
| 37 |
+
Project-URL: CI, https://github.com/mborsetti/airportsdata/actions
|
| 38 |
+
Keywords: airports,aerodromes,ICAO,IATA
|
| 39 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 40 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 41 |
+
Classifier: Programming Language :: Python
|
| 42 |
+
Classifier: Programming Language :: Python :: 3
|
| 43 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 44 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 45 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 46 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 47 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 48 |
+
Classifier: Operating System :: OS Independent
|
| 49 |
+
Classifier: Topic :: Database
|
| 50 |
+
Classifier: Intended Audience :: Developers
|
| 51 |
+
Classifier: Typing :: Typed
|
| 52 |
+
Requires-Python: >=3.9
|
| 53 |
+
Description-Content-Type: text/x-rst
|
| 54 |
+
License-File: LICENSE
|
| 55 |
+
|
| 56 |
+
========================
|
| 57 |
+
airportsdata |downloads|
|
| 58 |
+
========================
|
| 59 |
+
|
| 60 |
+
.. |ICAO| replace:: 28,237
|
| 61 |
+
|
| 62 |
+
.. |IATA| replace:: 7,876
|
| 63 |
+
|
| 64 |
+
.. |LID| replace:: 12,604
|
| 65 |
+
|
| 66 |
+
.. |pyversion| image:: https://img.shields.io/pypi/v/airportsdata.svg
|
| 67 |
+
:target: https://pypi.org/project/airportsdata/
|
| 68 |
+
:alt: pypi version
|
| 69 |
+
.. |support| image:: https://img.shields.io/pypi/pyversions/airportsdata.svg
|
| 70 |
+
:target: https://pypi.org/project/airportsdata/
|
| 71 |
+
:alt: supported Python version
|
| 72 |
+
.. |pypi_version| image:: https://img.shields.io/pypi/v/airportsdata.svg?label=
|
| 73 |
+
:target: https://pypi.org/project/airportsdata/
|
| 74 |
+
:alt: PyPI version
|
| 75 |
+
.. |format| image:: https://img.shields.io/pypi/format/airportsdata.svg
|
| 76 |
+
:target: https://pypi.org/project/airportsdata/
|
| 77 |
+
:alt: Kit format
|
| 78 |
+
.. |downloads| image:: https://static.pepy.tech/badge/airportsdata
|
| 79 |
+
:target: https://www.pepy.tech/project/airportsdata
|
| 80 |
+
:alt: PyPI downloads
|
| 81 |
+
.. |license| image:: https://img.shields.io/pypi/l/airportsdata.svg
|
| 82 |
+
:target: https://pypi.org/project/airportsdata/
|
| 83 |
+
:alt: license
|
| 84 |
+
.. |issues| image:: https://img.shields.io/github/issues-raw/mborsetti/airportsdata
|
| 85 |
+
:target: https://github.com/mborsetti/airportsdata/issues
|
| 86 |
+
:alt: issues
|
| 87 |
+
.. |CI| image:: https://github.com/mborsetti/airportsdata/actions/workflows/ci-cd.yaml/badge.svg?event=push
|
| 88 |
+
:target: https://github.com/mborsetti/airportsdata/actions
|
| 89 |
+
:alt: CI testing status
|
| 90 |
+
.. |coveralls| image:: https://coveralls.io/repos/github/mborsetti/airportsdata/badge.svg?branch=main
|
| 91 |
+
:target: https://coveralls.io/github/mborsetti/airportsdata?branch=main
|
| 92 |
+
:alt: code coverage by Coveralls
|
| 93 |
+
.. |status| image:: https://img.shields.io/pypi/status/airportsdata.svg
|
| 94 |
+
:target: https://pypi.org/project/airportsdata/
|
| 95 |
+
:alt: Package stability
|
| 96 |
+
.. |security| image:: https://img.shields.io/badge/security-bandit-yellow.svg
|
| 97 |
+
:target: https://github.com/PyCQA/bandit
|
| 98 |
+
:alt: Security Status
|
| 99 |
+
|
| 100 |
+
Extensive database of location and timezone data for nearly every operational airport and landing strip in the world,
|
| 101 |
+
with |ICAO| entries.
|
| 102 |
+
|
| 103 |
+
Each entry consists of the following data:
|
| 104 |
+
|
| 105 |
+
* ``icao``: ICAO 4-letter Location Indicator (Doc 7910) or (if none) an internal Pseudo-ICAO Identifier [#]_ (|ICAO|
|
| 106 |
+
entries);
|
| 107 |
+
* ``iata``: IATA 3-letter Location Code (|IATA| entries) or an empty string [#]_;
|
| 108 |
+
* ``name``: Official name (diacritized latin script);
|
| 109 |
+
* ``city``: City (diacritized latin script), ideally using the local language;
|
| 110 |
+
* ``subd``: Subdivision (e.g. state, province, region, etc.), ideally using the local-language or English names of
|
| 111 |
+
`ISO 3166-2 <https://en.wikipedia.org/wiki/ISO_3166-2#Current_codes>`__;
|
| 112 |
+
* ``country``: `ISO 3166-1 <https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes>`__ alpha-2 country code
|
| 113 |
+
(plus ``XK`` for Kosovo);
|
| 114 |
+
* ``elevation``: MSL elevation of the highest point of the landing area, in feet (warning: it is often wrong);
|
| 115 |
+
* ``lat``: Latitude (decimal) of the `airport reference point
|
| 116 |
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
| 117 |
+
* ``lon``: Longitude (decimal) of the `airport reference point
|
| 118 |
+
<https://en.wikipedia.org/wiki/Airport_reference_point>`__ (max 5 decimal digits);
|
| 119 |
+
* ``tz``: Timezone expressed as a `tz database name <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`__
|
| 120 |
+
(IANA-compliant);
|
| 121 |
+
* ``lid``: U.S. FAA Location Identifier (|LID| entries), or an empty string.
|
| 122 |
+
|
| 123 |
+
.. [#] See `here <https://github.com/mborsetti/airportsdata/blob/main/README_identifiers.rst>`__ for an explanation on
|
| 124 |
+
how the Pseudo-ICAO Identifier is generated for airports and seaplane bases without an ICAO 4-letter Location
|
| 125 |
+
Indicator.
|
| 126 |
+
|
| 127 |
+
.. [#] IATA Multi Airport Cities are not not airports and therfore not included, but we provide a database and a Python
|
| 128 |
+
function that returns the above data for all the airports of a IATA MAC. Please see documentation `here
|
| 129 |
+
<https://github.com/mborsetti/airportsdata/blob/main/README_IATA.rst>`__.
|
| 130 |
+
|
| 131 |
+
Best efforts are placed to review all contributions for accuracy, but accuracy cannot be guaranteed nor should be
|
| 132 |
+
expected by users.
|
| 133 |
+
|
| 134 |
+
Important notes:
|
| 135 |
+
|
| 136 |
+
* Timezone was originally sourced from `TimeZoneDB <https://timezonedb.com>`__;
|
| 137 |
+
* No historical data (closed airports are removed).
|
| 138 |
+
|
| 139 |
+
Please report any issues you may find `here
|
| 140 |
+
<https://github.com/mborsetti/airportsdata/blob/main/CONTRIBUTING.rst>`__.
|
| 141 |
+
|
| 142 |
+
This project is a fork of https://github.com/mwgg/Airports. All new data submitted in this fork have been validated
|
| 143 |
+
against national `Aeronautical Information Publications (AIP) or equivalent
|
| 144 |
+
<https://github.com/mborsetti/airportsdata/blob/main/README_AIP.rst>`__ (or
|
| 145 |
+
ARINC database) and `IATA <https://www.iata.org/en/publications/directories/code-search/>`__ before publishing.
|
| 146 |
+
|
| 147 |
+
Raw data
|
| 148 |
+
========
|
| 149 |
+
|
| 150 |
+
A CSV (comma separated values) file, with headers and encoded in UTF-8, is downloadable from GitHub `here
|
| 151 |
+
<https://github.com/mborsetti/airportsdata/raw/main/airportsdata/airports.csv>`__.
|
| 152 |
+
|
| 153 |
+
Python
|
| 154 |
+
======
|
| 155 |
+
|pyversion| |support| |format| |status| |security| |CI| |coveralls| |issues|
|
| 156 |
+
|
| 157 |
+
Install from `PyPi <https://pypi.org/project/airportsdata/>`__ using pip:
|
| 158 |
+
|
| 159 |
+
.. code-block:: bash
|
| 160 |
+
|
| 161 |
+
pip install -U airportsdata
|
| 162 |
+
|
| 163 |
+
Once installed, to load the data into a dict:
|
| 164 |
+
|
| 165 |
+
.. code-block:: python
|
| 166 |
+
|
| 167 |
+
import airportsdata
|
| 168 |
+
airports = airportsdata.load() # key is the ICAO identifier (the default)
|
| 169 |
+
print(airports['KJFK'])
|
| 170 |
+
|
| 171 |
+
or
|
| 172 |
+
|
| 173 |
+
.. code-block:: python
|
| 174 |
+
|
| 175 |
+
import airportsdata
|
| 176 |
+
airports = airportsdata.load('IATA') # key is the IATA location code
|
| 177 |
+
print(airports['JFK'])
|
| 178 |
+
|
| 179 |
+
or
|
| 180 |
+
|
| 181 |
+
.. code-block:: python
|
| 182 |
+
|
| 183 |
+
import airportsdata
|
| 184 |
+
airports = airportsdata.load('LID') # key is the FAA LID
|
| 185 |
+
print(airports['01AA'])
|
| 186 |
+
|
| 187 |
+
Older Python versions are supported for 3 years after being obsoleted by a new major release (i.e. about 4 years
|
| 188 |
+
since their original release).
|
| 189 |
+
|
| 190 |
+
License |license|
|
| 191 |
+
=================
|
| 192 |
+
|
| 193 |
+
Released under the `MIT License <https://opensource.org/licenses/MIT>`__ (see license `here
|
| 194 |
+
<https://github.com/mborsetti/airportsdata/blob/main/LICENSE>`__).
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/RECORD
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
airportsdata-20241001.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
airportsdata-20241001.dist-info/LICENSE,sha256=Gra_Nl4fahiDq2oveX52GyIQgbUqMyc9hsFX_VYhBr4,1191
|
| 3 |
+
airportsdata-20241001.dist-info/METADATA,sha256=xZmo6PVCkbbv3Shhg0Oqocc0ZuC-XY1QDDPRO8q6dhw,8918
|
| 4 |
+
airportsdata-20241001.dist-info/RECORD,,
|
| 5 |
+
airportsdata-20241001.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
| 6 |
+
airportsdata-20241001.dist-info/top_level.txt,sha256=pwno2lCh8ojWgA5MI3oKaEO0U96yNrH106dZIvhEbgE,13
|
| 7 |
+
airportsdata/__init__.py,sha256=fUFo8sBUvVeZiWXRmWZ3Udxi5TSoM4WZIvv_KngF3Cc,5261
|
| 8 |
+
airportsdata/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
airportsdata/airports.csv,sha256=koANA3k5geIpWLnSzKML0CUOGKSCxkpAx9R8Chiuoio,3040844
|
| 10 |
+
airportsdata/iata_macs.csv,sha256=jgeMECojIRDZ5e6JcTYQF0NRzGOCdJK9YCf-nB0u3Iw,4061
|
| 11 |
+
airportsdata/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (75.1.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
.venv/lib/python3.11/site-packages/airportsdata-20241001.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
airportsdata
|
.venv/lib/python3.11/site-packages/attr/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (3.1 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/_cmp.cpython-311.pyc
ADDED
|
Binary file (5.38 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/_compat.cpython-311.pyc
ADDED
|
Binary file (3.59 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/_config.cpython-311.pyc
ADDED
|
Binary file (1.17 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/_next_gen.cpython-311.pyc
ADDED
|
Binary file (24.9 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/exceptions.cpython-311.pyc
ADDED
|
Binary file (4.15 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/filters.cpython-311.pyc
ADDED
|
Binary file (3.18 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/attr/__pycache__/validators.cpython-311.pyc
ADDED
|
Binary file (28.5 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright [yyyy] [name of copyright owner]
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: google-auth
|
| 3 |
+
Version: 2.38.0
|
| 4 |
+
Summary: Google Authentication Library
|
| 5 |
+
Home-page: https://github.com/googleapis/google-auth-library-python
|
| 6 |
+
Author: Google Cloud Platform
|
| 7 |
+
Author-email: googleapis-packages@google.com
|
| 8 |
+
License: Apache 2.0
|
| 9 |
+
Keywords: google auth oauth client
|
| 10 |
+
Classifier: Programming Language :: Python :: 3
|
| 11 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 12 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 13 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 17 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 18 |
+
Classifier: Intended Audience :: Developers
|
| 19 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 20 |
+
Classifier: Operating System :: POSIX
|
| 21 |
+
Classifier: Operating System :: Microsoft :: Windows
|
| 22 |
+
Classifier: Operating System :: MacOS :: MacOS X
|
| 23 |
+
Classifier: Operating System :: OS Independent
|
| 24 |
+
Classifier: Topic :: Internet :: WWW/HTTP
|
| 25 |
+
Requires-Python: >=3.7
|
| 26 |
+
License-File: LICENSE
|
| 27 |
+
Requires-Dist: cachetools<6.0,>=2.0.0
|
| 28 |
+
Requires-Dist: pyasn1-modules>=0.2.1
|
| 29 |
+
Requires-Dist: rsa<5,>=3.1.4
|
| 30 |
+
Provides-Extra: aiohttp
|
| 31 |
+
Requires-Dist: aiohttp<4.0.0.dev0,>=3.6.2; extra == "aiohttp"
|
| 32 |
+
Requires-Dist: requests<3.0.0.dev0,>=2.20.0; extra == "aiohttp"
|
| 33 |
+
Provides-Extra: enterprise_cert
|
| 34 |
+
Requires-Dist: cryptography; extra == "enterprise-cert"
|
| 35 |
+
Requires-Dist: pyopenssl; extra == "enterprise-cert"
|
| 36 |
+
Provides-Extra: pyjwt
|
| 37 |
+
Requires-Dist: pyjwt>=2.0; extra == "pyjwt"
|
| 38 |
+
Requires-Dist: cryptography>=38.0.3; extra == "pyjwt"
|
| 39 |
+
Provides-Extra: pyopenssl
|
| 40 |
+
Requires-Dist: pyopenssl>=20.0.0; extra == "pyopenssl"
|
| 41 |
+
Requires-Dist: cryptography>=38.0.3; extra == "pyopenssl"
|
| 42 |
+
Provides-Extra: reauth
|
| 43 |
+
Requires-Dist: pyu2f>=0.1.5; extra == "reauth"
|
| 44 |
+
Provides-Extra: requests
|
| 45 |
+
Requires-Dist: requests<3.0.0.dev0,>=2.20.0; extra == "requests"
|
| 46 |
+
|
| 47 |
+
Google Auth Python Library
|
| 48 |
+
==========================
|
| 49 |
+
|
| 50 |
+
|pypi|
|
| 51 |
+
|
| 52 |
+
This library simplifies using Google's various server-to-server authentication
|
| 53 |
+
mechanisms to access Google APIs.
|
| 54 |
+
|
| 55 |
+
.. |pypi| image:: https://img.shields.io/pypi/v/google-auth.svg
|
| 56 |
+
:target: https://pypi.python.org/pypi/google-auth
|
| 57 |
+
|
| 58 |
+
Installing
|
| 59 |
+
----------
|
| 60 |
+
|
| 61 |
+
You can install using `pip`_::
|
| 62 |
+
|
| 63 |
+
$ pip install google-auth
|
| 64 |
+
|
| 65 |
+
.. _pip: https://pip.pypa.io/en/stable/
|
| 66 |
+
|
| 67 |
+
For more information on setting up your Python development environment, please refer to `Python Development Environment Setup Guide`_ for Google Cloud Platform.
|
| 68 |
+
|
| 69 |
+
.. _`Python Development Environment Setup Guide`: https://cloud.google.com/python/docs/setup
|
| 70 |
+
|
| 71 |
+
Extras
|
| 72 |
+
------
|
| 73 |
+
|
| 74 |
+
google-auth has few extras that you can install. For example::
|
| 75 |
+
|
| 76 |
+
$ pip install google-auth[pyopenssl]
|
| 77 |
+
|
| 78 |
+
Note that the extras pyopenssl and enterprise_cert should not be used together because they use conflicting versions of `cryptography`_.
|
| 79 |
+
|
| 80 |
+
.. _`cryptography`: https://cryptography.io/en/latest/
|
| 81 |
+
|
| 82 |
+
Supported Python Versions
|
| 83 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 84 |
+
Python >= 3.7
|
| 85 |
+
|
| 86 |
+
**NOTE**:
|
| 87 |
+
Python 3.7 was marked as `unsupported`_ by the python community in June 2023.
|
| 88 |
+
We recommend that all developers upgrade to Python 3.8 and newer as soon as
|
| 89 |
+
they can. Support for Python 3.7 will be removed from this library after
|
| 90 |
+
January 1 2024. Previous releases that support Python 3.7 will continue to be available
|
| 91 |
+
for download, but releases after January 1 2024 will only target Python 3.8 and
|
| 92 |
+
newer.
|
| 93 |
+
|
| 94 |
+
.. _unsupported: https://devguide.python.org/versions/#unsupported-versions
|
| 95 |
+
|
| 96 |
+
Unsupported Python Versions
|
| 97 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 98 |
+
- Python == 2.7: The last version of this library with support for Python 2.7
|
| 99 |
+
was `google.auth == 1.34.0`.
|
| 100 |
+
|
| 101 |
+
- Python 3.5: The last version of this library with support for Python 3.5
|
| 102 |
+
was `google.auth == 1.23.0`.
|
| 103 |
+
|
| 104 |
+
- Python 3.6: The last version of this library with support for Python 3.6
|
| 105 |
+
was `google.auth == 2.22.0`.
|
| 106 |
+
|
| 107 |
+
Documentation
|
| 108 |
+
-------------
|
| 109 |
+
|
| 110 |
+
Google Auth Python Library has usage and reference documentation at https://googleapis.dev/python/google-auth/latest/index.html.
|
| 111 |
+
|
| 112 |
+
Current Maintainers
|
| 113 |
+
-------------------
|
| 114 |
+
- googleapis-auth@google.com
|
| 115 |
+
|
| 116 |
+
Authors
|
| 117 |
+
-------
|
| 118 |
+
|
| 119 |
+
- `@theacodes <https://github.com/theacodes>`_ (Thea Flowers)
|
| 120 |
+
- `@dhermes <https://github.com/dhermes>`_ (Danny Hermes)
|
| 121 |
+
- `@lukesneeringer <https://github.com/lukesneeringer>`_ (Luke Sneeringer)
|
| 122 |
+
- `@busunkim96 <https://github.com/busunkim96>`_ (Bu Sun Kim)
|
| 123 |
+
|
| 124 |
+
Contributing
|
| 125 |
+
------------
|
| 126 |
+
|
| 127 |
+
Contributions to this library are always welcome and highly encouraged.
|
| 128 |
+
|
| 129 |
+
See `CONTRIBUTING.rst`_ for more information on how to get started.
|
| 130 |
+
|
| 131 |
+
.. _CONTRIBUTING.rst: https://github.com/googleapis/google-auth-library-python/blob/main/CONTRIBUTING.rst
|
| 132 |
+
|
| 133 |
+
License
|
| 134 |
+
-------
|
| 135 |
+
|
| 136 |
+
Apache 2.0 - See `the LICENSE`_ for more information.
|
| 137 |
+
|
| 138 |
+
.. _the LICENSE: https://github.com/googleapis/google-auth-library-python/blob/main/LICENSE
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
google/auth/__init__.py,sha256=wg5MWwRk8nfJFMmUMU2gLirrPdGe9NMwqLkdSwdFwE8,1639
|
| 2 |
+
google/auth/__pycache__/__init__.cpython-311.pyc,,
|
| 3 |
+
google/auth/__pycache__/_cloud_sdk.cpython-311.pyc,,
|
| 4 |
+
google/auth/__pycache__/_credentials_async.cpython-311.pyc,,
|
| 5 |
+
google/auth/__pycache__/_credentials_base.cpython-311.pyc,,
|
| 6 |
+
google/auth/__pycache__/_default.cpython-311.pyc,,
|
| 7 |
+
google/auth/__pycache__/_default_async.cpython-311.pyc,,
|
| 8 |
+
google/auth/__pycache__/_exponential_backoff.cpython-311.pyc,,
|
| 9 |
+
google/auth/__pycache__/_helpers.cpython-311.pyc,,
|
| 10 |
+
google/auth/__pycache__/_jwt_async.cpython-311.pyc,,
|
| 11 |
+
google/auth/__pycache__/_oauth2client.cpython-311.pyc,,
|
| 12 |
+
google/auth/__pycache__/_refresh_worker.cpython-311.pyc,,
|
| 13 |
+
google/auth/__pycache__/_service_account_info.cpython-311.pyc,,
|
| 14 |
+
google/auth/__pycache__/api_key.cpython-311.pyc,,
|
| 15 |
+
google/auth/__pycache__/app_engine.cpython-311.pyc,,
|
| 16 |
+
google/auth/__pycache__/aws.cpython-311.pyc,,
|
| 17 |
+
google/auth/__pycache__/credentials.cpython-311.pyc,,
|
| 18 |
+
google/auth/__pycache__/downscoped.cpython-311.pyc,,
|
| 19 |
+
google/auth/__pycache__/environment_vars.cpython-311.pyc,,
|
| 20 |
+
google/auth/__pycache__/exceptions.cpython-311.pyc,,
|
| 21 |
+
google/auth/__pycache__/external_account.cpython-311.pyc,,
|
| 22 |
+
google/auth/__pycache__/external_account_authorized_user.cpython-311.pyc,,
|
| 23 |
+
google/auth/__pycache__/iam.cpython-311.pyc,,
|
| 24 |
+
google/auth/__pycache__/identity_pool.cpython-311.pyc,,
|
| 25 |
+
google/auth/__pycache__/impersonated_credentials.cpython-311.pyc,,
|
| 26 |
+
google/auth/__pycache__/jwt.cpython-311.pyc,,
|
| 27 |
+
google/auth/__pycache__/metrics.cpython-311.pyc,,
|
| 28 |
+
google/auth/__pycache__/pluggable.cpython-311.pyc,,
|
| 29 |
+
google/auth/__pycache__/version.cpython-311.pyc,,
|
| 30 |
+
google/auth/_cloud_sdk.py,sha256=u7tbE3KdHBCzZK8ka47xG3CHHtF0DhFDjmPSgz8lwXg,5212
|
| 31 |
+
google/auth/_credentials_async.py,sha256=bHB28wMULOIEMmYqKEOU06A4co7uIXPcnfVC_TaA6KY,6802
|
| 32 |
+
google/auth/_credentials_base.py,sha256=KxdCZyoFyvrfWhJbNnuYkpUhxs0bmbxYvcH8-xp5hUs,2692
|
| 33 |
+
google/auth/_default.py,sha256=xNeiYdYKhEYuAGap1ATDG9GrMUAfFO1_Sow-CenvBoE,30312
|
| 34 |
+
google/auth/_default_async.py,sha256=r4bFozWfioQa4lIEC-psuRsLiVhnJbuW-uQ0daj7s3Q,11575
|
| 35 |
+
google/auth/_exponential_backoff.py,sha256=qxA9ek80rBkoARx0Egl2b1MlYU0D-pQNVqgCmUh-lgU,5372
|
| 36 |
+
google/auth/_helpers.py,sha256=7Zm-uwaZWyFb3fE2JQA-sJUTSBvltTgZkNkMGc7raRo,8236
|
| 37 |
+
google/auth/_jwt_async.py,sha256=5mGab5CkdnBMkQkS4mtNkwFkktp1jBw6G1sYQk8bYKY,5972
|
| 38 |
+
google/auth/_oauth2client.py,sha256=hPxcl_8q6Oxr0hOHPUWaWObxI85Pv-0q6kZhRUrT5oY,5855
|
| 39 |
+
google/auth/_refresh_worker.py,sha256=7apJkFsD9oL1yz1K7O8v-YN3f3TdNBiJdd7_Wmq6zpE,3375
|
| 40 |
+
google/auth/_service_account_info.py,sha256=KGruc_OxS7O7_EADD4JEIjjz_-5Xa1_rlgk1t0p1nvk,2816
|
| 41 |
+
google/auth/aio/__init__.py,sha256=e3ToAxXNHhqJLBgW8B66650xdqrTCZDLcwP2p5DhCPM,869
|
| 42 |
+
google/auth/aio/__pycache__/__init__.cpython-311.pyc,,
|
| 43 |
+
google/auth/aio/__pycache__/credentials.cpython-311.pyc,,
|
| 44 |
+
google/auth/aio/credentials.py,sha256=lXY0_SJ9c36Mzp47fN4a8JT5HfNzFQtIIwsZEwzoDR4,5273
|
| 45 |
+
google/auth/aio/transport/__init__.py,sha256=8dQWHpube1IeWw02q6AvMRTM5V_2iN4y3UMLenbmUUQ,4692
|
| 46 |
+
google/auth/aio/transport/__pycache__/__init__.cpython-311.pyc,,
|
| 47 |
+
google/auth/aio/transport/__pycache__/aiohttp.cpython-311.pyc,,
|
| 48 |
+
google/auth/aio/transport/__pycache__/sessions.cpython-311.pyc,,
|
| 49 |
+
google/auth/aio/transport/aiohttp.py,sha256=u-tFrcYh2P06P4pKY2o56e7nuN-dXPMZhi3q6Q7YDGQ,6729
|
| 50 |
+
google/auth/aio/transport/sessions.py,sha256=RcRHfkeo_ppEY1o8ts8aJqw76y54I8D0P8QT7yFq4aI,10388
|
| 51 |
+
google/auth/api_key.py,sha256=PeieTYceHJIFCo0zQo1EA9NEDL_Ie6S78qmD-6Ig17s,2583
|
| 52 |
+
google/auth/app_engine.py,sha256=LuEaoWM1UwcIUJ6OrLza0tTpqJBXbtzZ3XjN0C-6Wvk,6121
|
| 53 |
+
google/auth/aws.py,sha256=2V5NLhboorkPLLwnA87VuyH9imruake6qhyHKV_rVYM,34568
|
| 54 |
+
google/auth/compute_engine/__init__.py,sha256=BqeTka-oyHFATkys3SGKRlOyWQ8mVV0vVaP2hOwV4Qw,910
|
| 55 |
+
google/auth/compute_engine/__pycache__/__init__.cpython-311.pyc,,
|
| 56 |
+
google/auth/compute_engine/__pycache__/_metadata.cpython-311.pyc,,
|
| 57 |
+
google/auth/compute_engine/__pycache__/credentials.cpython-311.pyc,,
|
| 58 |
+
google/auth/compute_engine/_metadata.py,sha256=nmsegMDH_mLKrdNQcX75y3_szSyoeHo682Bj-uWV_o0,12686
|
| 59 |
+
google/auth/compute_engine/credentials.py,sha256=CxuxQkA-df1wSiTmk9ddXRRI8f8OgiaEvl_bvOt-J3A,19025
|
| 60 |
+
google/auth/credentials.py,sha256=l0g0iATMCpJnJXU5aE6YD850yBnZpshdYyDrYzhmE40,18700
|
| 61 |
+
google/auth/crypt/__init__.py,sha256=xxBMOPuzD-XOxPvzkleLa2oj4u-9FSjnFmUN3PBk00s,3324
|
| 62 |
+
google/auth/crypt/__pycache__/__init__.cpython-311.pyc,,
|
| 63 |
+
google/auth/crypt/__pycache__/_cryptography_rsa.cpython-311.pyc,,
|
| 64 |
+
google/auth/crypt/__pycache__/_helpers.cpython-311.pyc,,
|
| 65 |
+
google/auth/crypt/__pycache__/_python_rsa.cpython-311.pyc,,
|
| 66 |
+
google/auth/crypt/__pycache__/base.cpython-311.pyc,,
|
| 67 |
+
google/auth/crypt/__pycache__/es256.cpython-311.pyc,,
|
| 68 |
+
google/auth/crypt/__pycache__/rsa.cpython-311.pyc,,
|
| 69 |
+
google/auth/crypt/_cryptography_rsa.py,sha256=o2QTRkfDRLtEBiq-fbpbTWypvxaxUDwzlx2NpXG9o0w,5158
|
| 70 |
+
google/auth/crypt/_helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 71 |
+
google/auth/crypt/_python_rsa.py,sha256=L0kgvPXVdEGhajzxLRIgdk2T9rY0nlThrSlSz8Hc8XY,6123
|
| 72 |
+
google/auth/crypt/base.py,sha256=3CJrnQsppR6h-WnTRqSrt1hPEQVkHcwNIVJ_B5M00hY,4190
|
| 73 |
+
google/auth/crypt/es256.py,sha256=hXyeia3g6_TZf-UYdZVzFKgbPrLlgSuR1mMvYKSYqbg,6251
|
| 74 |
+
google/auth/crypt/rsa.py,sha256=QI17aKQsX3gdbJkBef-zsm-X_YBjBollCaoA65Am-WI,1109
|
| 75 |
+
google/auth/downscoped.py,sha256=KmmC8lbBWUFUsIYt1VpcbTXs3yYJYXteH19qdZQgobA,21793
|
| 76 |
+
google/auth/environment_vars.py,sha256=ML9aFh5gwRStBDjn8BQSQHyWsA-OcMn-RB5FRMM8qOw,3297
|
| 77 |
+
google/auth/exceptions.py,sha256=8oEeB_1UirJIyBoglQRpCFjCOcxcTaLr6EpBrrxjeEs,3193
|
| 78 |
+
google/auth/external_account.py,sha256=v-Qln5KsbXYlO2xPlIxeGMBY5iA4Atj2cP-KgbF2CpY,25977
|
| 79 |
+
google/auth/external_account_authorized_user.py,sha256=-garTidaTqA8XNOPdBxJl6tfx-ub_-dr7WPVKEI2eAs,13987
|
| 80 |
+
google/auth/iam.py,sha256=DQcJ127yejPqQa20jwzrGfiWffiWioAYkxZI4cQAUm8,4674
|
| 81 |
+
google/auth/identity_pool.py,sha256=zroaND7aE1nMNs53Pf-84OpybRmG2MT4nLAfPQtz_t8,18734
|
| 82 |
+
google/auth/impersonated_credentials.py,sha256=Jiet31lLn5hqZv2uw114dF-e1lwH_v506E7QCaHwTgM,21900
|
| 83 |
+
google/auth/jwt.py,sha256=1m_arp5x-4I5UTDaK9y50PSlKnUhnSKFyJW95k3-7cQ,31096
|
| 84 |
+
google/auth/metrics.py,sha256=wx3m95QQCF885wYvPL4T01CHOdCBN5JvFCtbOakd98Q,5614
|
| 85 |
+
google/auth/pluggable.py,sha256=peGQ4izmkZ3Fna7fjhBhQVXjtDBcHK12uEAteMyJ8s0,17322
|
| 86 |
+
google/auth/py.typed,sha256=l05_LTgi3oy-einKBrw66s6aavgzG2o-SekKPOY3ayM,74
|
| 87 |
+
google/auth/transport/__init__.py,sha256=Bc9Tx4qozvP1g1USD8pvk7NEVE6hgXrpO-FH2WQFkkU,3621
|
| 88 |
+
google/auth/transport/__pycache__/__init__.cpython-311.pyc,,
|
| 89 |
+
google/auth/transport/__pycache__/_aiohttp_requests.cpython-311.pyc,,
|
| 90 |
+
google/auth/transport/__pycache__/_custom_tls_signer.cpython-311.pyc,,
|
| 91 |
+
google/auth/transport/__pycache__/_http_client.cpython-311.pyc,,
|
| 92 |
+
google/auth/transport/__pycache__/_mtls_helper.cpython-311.pyc,,
|
| 93 |
+
google/auth/transport/__pycache__/_requests_base.cpython-311.pyc,,
|
| 94 |
+
google/auth/transport/__pycache__/grpc.cpython-311.pyc,,
|
| 95 |
+
google/auth/transport/__pycache__/mtls.cpython-311.pyc,,
|
| 96 |
+
google/auth/transport/__pycache__/requests.cpython-311.pyc,,
|
| 97 |
+
google/auth/transport/__pycache__/urllib3.cpython-311.pyc,,
|
| 98 |
+
google/auth/transport/_aiohttp_requests.py,sha256=nPi885vxrNoXi5h9Mw3nHj5jYUH8aZ_9QQN0V4dDLAY,14609
|
| 99 |
+
google/auth/transport/_custom_tls_signer.py,sha256=ilLlKFNognkvOWcnlYAWmUIUo9YhSrTSAKLa05zQ8Do,9989
|
| 100 |
+
google/auth/transport/_http_client.py,sha256=j7Amhmg-ipWztX3W5zOs2kJUFFuGCs0PhI7ZMAvle50,3706
|
| 101 |
+
google/auth/transport/_mtls_helper.py,sha256=rhJ-QDEWeoiLGguwtMjruy6ObR89oqwtZ382sW1g3uM,14739
|
| 102 |
+
google/auth/transport/_requests_base.py,sha256=4y0tTMR_hPGeAmBSyCU6_moh99ZxJZ4CF79E2s-t7TA,1657
|
| 103 |
+
google/auth/transport/grpc.py,sha256=o6wDBMWKlTybwsE8CUdEcoEA2t_vdjRvQTGU9vcJPcc,13931
|
| 104 |
+
google/auth/transport/mtls.py,sha256=C1Ox7fB0DSEdNkIJ7q5ofrQ-_I_cj1JOJ8o5_Zzgb24,3968
|
| 105 |
+
google/auth/transport/requests.py,sha256=Bd-K1jvqkseiob-iho2CtYWYVj3ZbmXU8b0VHWA2aJ0,22351
|
| 106 |
+
google/auth/transport/urllib3.py,sha256=cQITCEXvu375iIP749bG5p96Sf2EVBsq63EbKRYkhTA,16049
|
| 107 |
+
google/auth/version.py,sha256=bLKSlZBveRs2P3ZXlbHinmywhxK6d-gRl3FcW8l_eZE,598
|
| 108 |
+
google/oauth2/__init__.py,sha256=IdFKxhIzlqNIalPgeB2P5hP6KkoxcpNk61hp7P2B85w,1196
|
| 109 |
+
google/oauth2/__pycache__/__init__.cpython-311.pyc,,
|
| 110 |
+
google/oauth2/__pycache__/_client.cpython-311.pyc,,
|
| 111 |
+
google/oauth2/__pycache__/_client_async.cpython-311.pyc,,
|
| 112 |
+
google/oauth2/__pycache__/_credentials_async.cpython-311.pyc,,
|
| 113 |
+
google/oauth2/__pycache__/_id_token_async.cpython-311.pyc,,
|
| 114 |
+
google/oauth2/__pycache__/_reauth_async.cpython-311.pyc,,
|
| 115 |
+
google/oauth2/__pycache__/_service_account_async.cpython-311.pyc,,
|
| 116 |
+
google/oauth2/__pycache__/challenges.cpython-311.pyc,,
|
| 117 |
+
google/oauth2/__pycache__/credentials.cpython-311.pyc,,
|
| 118 |
+
google/oauth2/__pycache__/gdch_credentials.cpython-311.pyc,,
|
| 119 |
+
google/oauth2/__pycache__/id_token.cpython-311.pyc,,
|
| 120 |
+
google/oauth2/__pycache__/reauth.cpython-311.pyc,,
|
| 121 |
+
google/oauth2/__pycache__/service_account.cpython-311.pyc,,
|
| 122 |
+
google/oauth2/__pycache__/sts.cpython-311.pyc,,
|
| 123 |
+
google/oauth2/__pycache__/utils.cpython-311.pyc,,
|
| 124 |
+
google/oauth2/__pycache__/webauthn_handler.cpython-311.pyc,,
|
| 125 |
+
google/oauth2/__pycache__/webauthn_handler_factory.cpython-311.pyc,,
|
| 126 |
+
google/oauth2/__pycache__/webauthn_types.cpython-311.pyc,,
|
| 127 |
+
google/oauth2/_client.py,sha256=XOtqZf3J9U5zW9x5v6zPSKeF_YlRNdYlqfzOZPepxdc,17338
|
| 128 |
+
google/oauth2/_client_async.py,sha256=gBB74HOw_UVT6i-84T4N_39YnyajYwP5Ih1Kmtsjeu8,10129
|
| 129 |
+
google/oauth2/_credentials_async.py,sha256=hUrucQkcYuYlyCdHMci8tzaVncnjQlFc2sAfNu5Dt8k,4474
|
| 130 |
+
google/oauth2/_id_token_async.py,sha256=o_DViJoWMGlL3zwTbW2unGDBfY569D_VMB4l7bx-Qpw,10115
|
| 131 |
+
google/oauth2/_reauth_async.py,sha256=C6k3f4T0aoVWItl8shYjOl5ngaoTJw3zKVhqHAeBXU0,11696
|
| 132 |
+
google/oauth2/_service_account_async.py,sha256=5-HBGWoHhbWpCRbd34YiopQepEsEf8gSiuMlSm5hN84,5131
|
| 133 |
+
google/oauth2/challenges.py,sha256=__yS2EcWXlgdLLP4inbk0QjJuyXnztpT9r2DCuXvieI,10404
|
| 134 |
+
google/oauth2/credentials.py,sha256=AqPdW8ymp1EnmiTgwyLdRxjaj2kISjHPw4Yh0JZUleI,24913
|
| 135 |
+
google/oauth2/gdch_credentials.py,sha256=CY6iPnPuc2OCIe1Zujwg1Mu9QSl1iGJqGOy6TkUleHw,9007
|
| 136 |
+
google/oauth2/id_token.py,sha256=tuSXv7rLo6Fqw33_fXud8xiX66K6zM0ox091BsfwcTI,12933
|
| 137 |
+
google/oauth2/py.typed,sha256=I0muXRRdbdpJoZ_VyheisiTTYcmjTAitQpNvuuh6fMw,76
|
| 138 |
+
google/oauth2/reauth.py,sha256=p9ybxvFyaSMM85jL2veKMM-DVb4TtrDVPNqsLeDPmyk,12845
|
| 139 |
+
google/oauth2/service_account.py,sha256=PyKtS9QfflVfIgdyRju1I1VFr8V3A57IGzxUSAYGmgA,32232
|
| 140 |
+
google/oauth2/sts.py,sha256=GjpFEvByl3EzyGt2v1kev6rvP7_uSQ3eTlpBK9vUhSc,6699
|
| 141 |
+
google/oauth2/utils.py,sha256=4crAdpKbDtobpQfXJc3uF6Zm6F3IzffvRSo-9h_515w,6315
|
| 142 |
+
google/oauth2/webauthn_handler.py,sha256=6hYiSDIFXlLwghsYf13ceDiOWdLYn6Dh7-YwSqTbLaA,2743
|
| 143 |
+
google/oauth2/webauthn_handler_factory.py,sha256=soE5cokZ3pLNbBo1HC6F1N-N-I-ir-DGlD0trGPCpBs,429
|
| 144 |
+
google/oauth2/webauthn_types.py,sha256=kaDu4Gouk07CEkP08PZ26XAeVHyGP-SGWbDGnH1l2IE,5386
|
| 145 |
+
google_auth-2.38.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 146 |
+
google_auth-2.38.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
| 147 |
+
google_auth-2.38.0.dist-info/METADATA,sha256=7R3Ery802jdDQ0WO_3fmiuQiZBXhMlp4Vllq6JPYnTg,4775
|
| 148 |
+
google_auth-2.38.0.dist-info/RECORD,,
|
| 149 |
+
google_auth-2.38.0.dist-info/WHEEL,sha256=OpXWERl2xLPRHTvd2ZXo_iluPEQd8uSbYkJ53NAER_Y,109
|
| 150 |
+
google_auth-2.38.0.dist-info/top_level.txt,sha256=BWmDiI8eoKfseZ5-MI2AW66GLJLNH4Lz23AXXTrIlyQ,23
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (75.3.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py2-none-any
|
| 5 |
+
Tag: py3-none-any
|
| 6 |
+
|
.venv/lib/python3.11/site-packages/google_auth-2.38.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
google
|
| 2 |
+
scripts
|
| 3 |
+
testing
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2016 Nathaniel J. Smith <njs@pobox.com> and other contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining
|
| 6 |
+
a copy of this software and associated documentation files (the
|
| 7 |
+
"Software"), to deal in the Software without restriction, including
|
| 8 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 9 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 10 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 11 |
+
the following conditions:
|
| 12 |
+
|
| 13 |
+
The above copyright notice and this permission notice shall be
|
| 14 |
+
included in all copies or substantial portions of the Software.
|
| 15 |
+
|
| 16 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 17 |
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 18 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 19 |
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
| 20 |
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
| 21 |
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 22 |
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: h11
|
| 3 |
+
Version: 0.14.0
|
| 4 |
+
Summary: A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
|
| 5 |
+
Home-page: https://github.com/python-hyper/h11
|
| 6 |
+
Author: Nathaniel J. Smith
|
| 7 |
+
Author-email: njs@pobox.com
|
| 8 |
+
License: MIT
|
| 9 |
+
Classifier: Development Status :: 3 - Alpha
|
| 10 |
+
Classifier: Intended Audience :: Developers
|
| 11 |
+
Classifier: License :: OSI Approved :: MIT License
|
| 12 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 13 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 14 |
+
Classifier: Programming Language :: Python :: 3
|
| 15 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 20 |
+
Classifier: Topic :: Internet :: WWW/HTTP
|
| 21 |
+
Classifier: Topic :: System :: Networking
|
| 22 |
+
Requires-Python: >=3.7
|
| 23 |
+
License-File: LICENSE.txt
|
| 24 |
+
Requires-Dist: typing-extensions ; python_version < "3.8"
|
| 25 |
+
|
| 26 |
+
h11
|
| 27 |
+
===
|
| 28 |
+
|
| 29 |
+
.. image:: https://travis-ci.org/python-hyper/h11.svg?branch=master
|
| 30 |
+
:target: https://travis-ci.org/python-hyper/h11
|
| 31 |
+
:alt: Automated test status
|
| 32 |
+
|
| 33 |
+
.. image:: https://codecov.io/gh/python-hyper/h11/branch/master/graph/badge.svg
|
| 34 |
+
:target: https://codecov.io/gh/python-hyper/h11
|
| 35 |
+
:alt: Test coverage
|
| 36 |
+
|
| 37 |
+
.. image:: https://readthedocs.org/projects/h11/badge/?version=latest
|
| 38 |
+
:target: http://h11.readthedocs.io/en/latest/?badge=latest
|
| 39 |
+
:alt: Documentation Status
|
| 40 |
+
|
| 41 |
+
This is a little HTTP/1.1 library written from scratch in Python,
|
| 42 |
+
heavily inspired by `hyper-h2 <https://hyper-h2.readthedocs.io/>`_.
|
| 43 |
+
|
| 44 |
+
It's a "bring-your-own-I/O" library; h11 contains no IO code
|
| 45 |
+
whatsoever. This means you can hook h11 up to your favorite network
|
| 46 |
+
API, and that could be anything you want: synchronous, threaded,
|
| 47 |
+
asynchronous, or your own implementation of `RFC 6214
|
| 48 |
+
<https://tools.ietf.org/html/rfc6214>`_ -- h11 won't judge you.
|
| 49 |
+
(Compare this to the current state of the art, where every time a `new
|
| 50 |
+
network API <https://trio.readthedocs.io/>`_ comes along then someone
|
| 51 |
+
gets to start over reimplementing the entire HTTP protocol from
|
| 52 |
+
scratch.) Cory Benfield made an `excellent blog post describing the
|
| 53 |
+
benefits of this approach
|
| 54 |
+
<https://lukasa.co.uk/2015/10/The_New_Hyper/>`_, or if you like video
|
| 55 |
+
then here's his `PyCon 2016 talk on the same theme
|
| 56 |
+
<https://www.youtube.com/watch?v=7cC3_jGwl_U>`_.
|
| 57 |
+
|
| 58 |
+
This also means that h11 is not immediately useful out of the box:
|
| 59 |
+
it's a toolkit for building programs that speak HTTP, not something
|
| 60 |
+
that could directly replace ``requests`` or ``twisted.web`` or
|
| 61 |
+
whatever. But h11 makes it much easier to implement something like
|
| 62 |
+
``requests`` or ``twisted.web``.
|
| 63 |
+
|
| 64 |
+
At a high level, working with h11 goes like this:
|
| 65 |
+
|
| 66 |
+
1) First, create an ``h11.Connection`` object to track the state of a
|
| 67 |
+
single HTTP/1.1 connection.
|
| 68 |
+
|
| 69 |
+
2) When you read data off the network, pass it to
|
| 70 |
+
``conn.receive_data(...)``; you'll get back a list of objects
|
| 71 |
+
representing high-level HTTP "events".
|
| 72 |
+
|
| 73 |
+
3) When you want to send a high-level HTTP event, create the
|
| 74 |
+
corresponding "event" object and pass it to ``conn.send(...)``;
|
| 75 |
+
this will give you back some bytes that you can then push out
|
| 76 |
+
through the network.
|
| 77 |
+
|
| 78 |
+
For example, a client might instantiate and then send a
|
| 79 |
+
``h11.Request`` object, then zero or more ``h11.Data`` objects for the
|
| 80 |
+
request body (e.g., if this is a POST), and then a
|
| 81 |
+
``h11.EndOfMessage`` to indicate the end of the message. Then the
|
| 82 |
+
server would then send back a ``h11.Response``, some ``h11.Data``, and
|
| 83 |
+
its own ``h11.EndOfMessage``. If either side violates the protocol,
|
| 84 |
+
you'll get a ``h11.ProtocolError`` exception.
|
| 85 |
+
|
| 86 |
+
h11 is suitable for implementing both servers and clients, and has a
|
| 87 |
+
pleasantly symmetric API: the events you send as a client are exactly
|
| 88 |
+
the ones that you receive as a server and vice-versa.
|
| 89 |
+
|
| 90 |
+
`Here's an example of a tiny HTTP client
|
| 91 |
+
<https://github.com/python-hyper/h11/blob/master/examples/basic-client.py>`_
|
| 92 |
+
|
| 93 |
+
It also has `a fine manual <https://h11.readthedocs.io/>`_.
|
| 94 |
+
|
| 95 |
+
FAQ
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
*Whyyyyy?*
|
| 99 |
+
|
| 100 |
+
I wanted to play with HTTP in `Curio
|
| 101 |
+
<https://curio.readthedocs.io/en/latest/tutorial.html>`__ and `Trio
|
| 102 |
+
<https://trio.readthedocs.io>`__, which at the time didn't have any
|
| 103 |
+
HTTP libraries. So I thought, no big deal, Python has, like, a dozen
|
| 104 |
+
different implementations of HTTP, surely I can find one that's
|
| 105 |
+
reusable. I didn't find one, but I did find Cory's call-to-arms
|
| 106 |
+
blog-post. So I figured, well, fine, if I have to implement HTTP from
|
| 107 |
+
scratch, at least I can make sure no-one *else* has to ever again.
|
| 108 |
+
|
| 109 |
+
*Should I use it?*
|
| 110 |
+
|
| 111 |
+
Maybe. You should be aware that it's a very young project. But, it's
|
| 112 |
+
feature complete and has an exhaustive test-suite and complete docs,
|
| 113 |
+
so the next step is for people to try using it and see how it goes
|
| 114 |
+
:-). If you do then please let us know -- if nothing else we'll want
|
| 115 |
+
to talk to you before making any incompatible changes!
|
| 116 |
+
|
| 117 |
+
*What are the features/limitations?*
|
| 118 |
+
|
| 119 |
+
Roughly speaking, it's trying to be a robust, complete, and non-hacky
|
| 120 |
+
implementation of the first "chapter" of the HTTP/1.1 spec: `RFC 7230:
|
| 121 |
+
HTTP/1.1 Message Syntax and Routing
|
| 122 |
+
<https://tools.ietf.org/html/rfc7230>`_. That is, it mostly focuses on
|
| 123 |
+
implementing HTTP at the level of taking bytes on and off the wire,
|
| 124 |
+
and the headers related to that, and tries to be anal about spec
|
| 125 |
+
conformance. It doesn't know about higher-level concerns like URL
|
| 126 |
+
routing, conditional GETs, cross-origin cookie policies, or content
|
| 127 |
+
negotiation. But it does know how to take care of framing,
|
| 128 |
+
cross-version differences in keep-alive handling, and the "obsolete
|
| 129 |
+
line folding" rule, so you can focus your energies on the hard /
|
| 130 |
+
interesting parts for your application, and it tries to support the
|
| 131 |
+
full specification in the sense that any useful HTTP/1.1 conformant
|
| 132 |
+
application should be able to use h11.
|
| 133 |
+
|
| 134 |
+
It's pure Python, and has no dependencies outside of the standard
|
| 135 |
+
library.
|
| 136 |
+
|
| 137 |
+
It has a test suite with 100.0% coverage for both statements and
|
| 138 |
+
branches.
|
| 139 |
+
|
| 140 |
+
Currently it supports Python 3 (testing on 3.7-3.10) and PyPy 3.
|
| 141 |
+
The last Python 2-compatible version was h11 0.11.x.
|
| 142 |
+
(Originally it had a Cython wrapper for `http-parser
|
| 143 |
+
<https://github.com/nodejs/http-parser>`_ and a beautiful nested state
|
| 144 |
+
machine implemented with ``yield from`` to postprocess the output. But
|
| 145 |
+
I had to take these out -- the new *parser* needs fewer lines-of-code
|
| 146 |
+
than the old *parser wrapper*, is written in pure Python, uses no
|
| 147 |
+
exotic language syntax, and has more features. It's sad, really; that
|
| 148 |
+
old state machine was really slick. I just need a few sentences here
|
| 149 |
+
to mourn that.)
|
| 150 |
+
|
| 151 |
+
I don't know how fast it is. I haven't benchmarked or profiled it yet,
|
| 152 |
+
so it's probably got a few pointless hot spots, and I've been trying
|
| 153 |
+
to err on the side of simplicity and robustness instead of
|
| 154 |
+
micro-optimization. But at the architectural level I tried hard to
|
| 155 |
+
avoid fundamentally bad decisions, e.g., I believe that all the
|
| 156 |
+
parsing algorithms remain linear-time even in the face of pathological
|
| 157 |
+
input like slowloris, and there are no byte-by-byte loops. (I also
|
| 158 |
+
believe that it maintains bounded memory usage in the face of
|
| 159 |
+
arbitrary/pathological input.)
|
| 160 |
+
|
| 161 |
+
The whole library is ~800 lines-of-code. You can read and understand
|
| 162 |
+
the whole thing in less than an hour. Most of the energy invested in
|
| 163 |
+
this so far has been spent on trying to keep things simple by
|
| 164 |
+
minimizing special-cases and ad hoc state manipulation; even though it
|
| 165 |
+
is now quite small and simple, I'm still annoyed that I haven't
|
| 166 |
+
figured out how to make it even smaller and simpler. (Unfortunately,
|
| 167 |
+
HTTP does not lend itself to simplicity.)
|
| 168 |
+
|
| 169 |
+
The API is ~feature complete and I don't expect the general outlines
|
| 170 |
+
to change much, but you can't judge an API's ergonomics until you
|
| 171 |
+
actually document and use it, so I'd expect some changes in the
|
| 172 |
+
details.
|
| 173 |
+
|
| 174 |
+
*How do I try it?*
|
| 175 |
+
|
| 176 |
+
.. code-block:: sh
|
| 177 |
+
|
| 178 |
+
$ pip install h11
|
| 179 |
+
$ git clone git@github.com:python-hyper/h11
|
| 180 |
+
$ cd h11/examples
|
| 181 |
+
$ python basic-client.py
|
| 182 |
+
|
| 183 |
+
and go from there.
|
| 184 |
+
|
| 185 |
+
*License?*
|
| 186 |
+
|
| 187 |
+
MIT
|
| 188 |
+
|
| 189 |
+
*Code of conduct?*
|
| 190 |
+
|
| 191 |
+
Contributors are requested to follow our `code of conduct
|
| 192 |
+
<https://github.com/python-hyper/h11/blob/master/CODE_OF_CONDUCT.md>`_ in
|
| 193 |
+
all project spaces.
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
h11-0.14.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
h11-0.14.0.dist-info/LICENSE.txt,sha256=N9tbuFkm2yikJ6JYZ_ELEjIAOuob5pzLhRE4rbjm82E,1124
|
| 3 |
+
h11-0.14.0.dist-info/METADATA,sha256=B7pZ0m7WBXNs17vl6hUH9bJTL9s37DaGvY31w7jNxSg,8175
|
| 4 |
+
h11-0.14.0.dist-info/RECORD,,
|
| 5 |
+
h11-0.14.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
| 6 |
+
h11-0.14.0.dist-info/top_level.txt,sha256=F7dC4jl3zeh8TGHEPaWJrMbeuoWbS379Gwdi-Yvdcis,4
|
| 7 |
+
h11/__init__.py,sha256=iO1KzkSO42yZ6ffg-VMgbx_ZVTWGUY00nRYEWn-s3kY,1507
|
| 8 |
+
h11/__pycache__/__init__.cpython-311.pyc,,
|
| 9 |
+
h11/__pycache__/_abnf.cpython-311.pyc,,
|
| 10 |
+
h11/__pycache__/_connection.cpython-311.pyc,,
|
| 11 |
+
h11/__pycache__/_events.cpython-311.pyc,,
|
| 12 |
+
h11/__pycache__/_headers.cpython-311.pyc,,
|
| 13 |
+
h11/__pycache__/_readers.cpython-311.pyc,,
|
| 14 |
+
h11/__pycache__/_receivebuffer.cpython-311.pyc,,
|
| 15 |
+
h11/__pycache__/_state.cpython-311.pyc,,
|
| 16 |
+
h11/__pycache__/_util.cpython-311.pyc,,
|
| 17 |
+
h11/__pycache__/_version.cpython-311.pyc,,
|
| 18 |
+
h11/__pycache__/_writers.cpython-311.pyc,,
|
| 19 |
+
h11/_abnf.py,sha256=ybixr0xsupnkA6GFAyMubuXF6Tc1lb_hF890NgCsfNc,4815
|
| 20 |
+
h11/_connection.py,sha256=eS2sorMD0zKLCFiB9lW9W9F_Nzny2tjHa4e6s1ujr1c,26539
|
| 21 |
+
h11/_events.py,sha256=LEfuvg1AbhHaVRwxCd0I-pFn9-ezUOaoL8o2Kvy1PBA,11816
|
| 22 |
+
h11/_headers.py,sha256=RqB8cd8CN0blYPzcLe5qeCh-phv6D1U_CHj4hs67lgQ,10230
|
| 23 |
+
h11/_readers.py,sha256=EbSed0jzwVUiD1nOPAeUcVE4Flf3wXkxfb8c06-OTBM,8383
|
| 24 |
+
h11/_receivebuffer.py,sha256=xrspsdsNgWFxRfQcTXxR8RrdjRXXTK0Io5cQYWpJ1Ws,5252
|
| 25 |
+
h11/_state.py,sha256=k1VL6SDbaPkSrZ-49ewCXDpuiUS69_46YhbWjuV1qEY,13300
|
| 26 |
+
h11/_util.py,sha256=LWkkjXyJaFlAy6Lt39w73UStklFT5ovcvo0TkY7RYuk,4888
|
| 27 |
+
h11/_version.py,sha256=LVyTdiZRzIIEv79UyOgbM5iUrJUllEzlCWaJEYBY1zc,686
|
| 28 |
+
h11/_writers.py,sha256=oFKm6PtjeHfbj4RLX7VB7KDc1gIY53gXG3_HR9ltmTA,5081
|
| 29 |
+
h11/py.typed,sha256=sow9soTwP9T_gEAQSVh7Gb8855h04Nwmhs2We-JRgZM,7
|
| 30 |
+
h11/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 31 |
+
h11/tests/__pycache__/__init__.cpython-311.pyc,,
|
| 32 |
+
h11/tests/__pycache__/helpers.cpython-311.pyc,,
|
| 33 |
+
h11/tests/__pycache__/test_against_stdlib_http.cpython-311.pyc,,
|
| 34 |
+
h11/tests/__pycache__/test_connection.cpython-311.pyc,,
|
| 35 |
+
h11/tests/__pycache__/test_events.cpython-311.pyc,,
|
| 36 |
+
h11/tests/__pycache__/test_headers.cpython-311.pyc,,
|
| 37 |
+
h11/tests/__pycache__/test_helpers.cpython-311.pyc,,
|
| 38 |
+
h11/tests/__pycache__/test_io.cpython-311.pyc,,
|
| 39 |
+
h11/tests/__pycache__/test_receivebuffer.cpython-311.pyc,,
|
| 40 |
+
h11/tests/__pycache__/test_state.cpython-311.pyc,,
|
| 41 |
+
h11/tests/__pycache__/test_util.cpython-311.pyc,,
|
| 42 |
+
h11/tests/data/test-file,sha256=ZJ03Rqs98oJw29OHzJg7LlMzyGQaRAY0r3AqBeM2wVU,65
|
| 43 |
+
h11/tests/helpers.py,sha256=a1EVG_p7xU4wRsa3tMPTRxuaKCmretok9sxXWvqfmQA,3355
|
| 44 |
+
h11/tests/test_against_stdlib_http.py,sha256=cojCHgHXFQ8gWhNlEEwl3trmOpN-5uDukRoHnElqo3A,3995
|
| 45 |
+
h11/tests/test_connection.py,sha256=ZbPLDPclKvjgjAhgk-WlCPBaf17c4XUIV2tpaW08jOI,38720
|
| 46 |
+
h11/tests/test_events.py,sha256=LPVLbcV-NvPNK9fW3rraR6Bdpz1hAlsWubMtNaJ5gHg,4657
|
| 47 |
+
h11/tests/test_headers.py,sha256=qd8T1Zenuz5GbD6wklSJ5G8VS7trrYgMV0jT-SMvqg8,5612
|
| 48 |
+
h11/tests/test_helpers.py,sha256=kAo0CEM4LGqmyyP2ZFmhsyq3UFJqoFfAbzu3hbWreRM,794
|
| 49 |
+
h11/tests/test_io.py,sha256=uCZVnjarkRBkudfC1ij-KSCQ71XWJhnkgkgWWkKgYPQ,16386
|
| 50 |
+
h11/tests/test_receivebuffer.py,sha256=3jGbeJM36Akqg_pAhPb7XzIn2NS6RhPg-Ryg8Eu6ytk,3454
|
| 51 |
+
h11/tests/test_state.py,sha256=rqll9WqFsJPE0zSrtCn9LH659mPKsDeXZ-DwXwleuBQ,8928
|
| 52 |
+
h11/tests/test_util.py,sha256=VO5L4nSFe4pgtSwKuv6u_6l0H7UeizF5WKuHTWreg70,2970
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.37.0)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py3-none-any
|
| 5 |
+
|
.venv/lib/python3.11/site-packages/h11-0.14.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
h11
|
.venv/lib/python3.11/site-packages/msgspec/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._core import (
|
| 2 |
+
DecodeError,
|
| 3 |
+
EncodeError,
|
| 4 |
+
Field as _Field,
|
| 5 |
+
Meta,
|
| 6 |
+
MsgspecError,
|
| 7 |
+
Raw,
|
| 8 |
+
Struct,
|
| 9 |
+
UnsetType,
|
| 10 |
+
UNSET,
|
| 11 |
+
NODEFAULT,
|
| 12 |
+
ValidationError,
|
| 13 |
+
defstruct,
|
| 14 |
+
convert,
|
| 15 |
+
to_builtins,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def field(*, default=NODEFAULT, default_factory=NODEFAULT, name=None):
|
| 20 |
+
return _Field(default=default, default_factory=default_factory, name=name)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
field.__doc__ = _Field.__doc__
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
from . import msgpack
|
| 27 |
+
from . import json
|
| 28 |
+
from . import yaml
|
| 29 |
+
from . import toml
|
| 30 |
+
from . import inspect
|
| 31 |
+
from . import structs
|
| 32 |
+
from ._version import get_versions
|
| 33 |
+
|
| 34 |
+
__version__ = get_versions()["version"]
|
| 35 |
+
del get_versions
|
.venv/lib/python3.11/site-packages/msgspec/__init__.pyi
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import enum
|
| 2 |
+
from typing import (
|
| 3 |
+
Any,
|
| 4 |
+
Callable,
|
| 5 |
+
ClassVar,
|
| 6 |
+
Dict,
|
| 7 |
+
Final,
|
| 8 |
+
Iterable,
|
| 9 |
+
Literal,
|
| 10 |
+
Mapping,
|
| 11 |
+
Optional,
|
| 12 |
+
Tuple,
|
| 13 |
+
Type,
|
| 14 |
+
TypeVar,
|
| 15 |
+
Union,
|
| 16 |
+
overload,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
from typing_extensions import dataclass_transform, Buffer
|
| 20 |
+
|
| 21 |
+
from . import inspect, json, msgpack, structs, toml, yaml
|
| 22 |
+
|
| 23 |
+
T = TypeVar("T")
|
| 24 |
+
|
| 25 |
+
class UnsetType(enum.Enum):
|
| 26 |
+
UNSET = "UNSET"
|
| 27 |
+
|
| 28 |
+
UNSET = UnsetType.UNSET
|
| 29 |
+
|
| 30 |
+
class _NoDefault(enum.Enum):
|
| 31 |
+
NODEFAULT = "NODEFAULT"
|
| 32 |
+
|
| 33 |
+
NODEFAULT = _NoDefault.NODEFAULT
|
| 34 |
+
|
| 35 |
+
@overload
|
| 36 |
+
def field(*, default: T, name: Optional[str] = None) -> T: ...
|
| 37 |
+
@overload
|
| 38 |
+
def field(*, default_factory: Callable[[], T], name: Optional[str] = None) -> T: ...
|
| 39 |
+
@overload
|
| 40 |
+
def field(*, name: Optional[str] = None) -> Any: ...
|
| 41 |
+
@dataclass_transform(field_specifiers=(field,))
|
| 42 |
+
class Struct:
|
| 43 |
+
__struct_fields__: ClassVar[Tuple[str, ...]]
|
| 44 |
+
__struct_config__: ClassVar[structs.StructConfig]
|
| 45 |
+
__match_args__: ClassVar[Tuple[str, ...]]
|
| 46 |
+
# A default __init__ so that Structs with unknown field types (say
|
| 47 |
+
# constructed by `defstruct`) won't error on every call to `__init__`
|
| 48 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
|
| 49 |
+
def __init_subclass__(
|
| 50 |
+
cls,
|
| 51 |
+
tag: Union[None, bool, str, int, Callable[[str], Union[str, int]]] = None,
|
| 52 |
+
tag_field: Union[None, str] = None,
|
| 53 |
+
rename: Union[
|
| 54 |
+
None,
|
| 55 |
+
Literal["lower", "upper", "camel", "pascal", "kebab"],
|
| 56 |
+
Callable[[str], Optional[str]],
|
| 57 |
+
Mapping[str, str],
|
| 58 |
+
] = None,
|
| 59 |
+
omit_defaults: bool = False,
|
| 60 |
+
forbid_unknown_fields: bool = False,
|
| 61 |
+
frozen: bool = False,
|
| 62 |
+
eq: bool = True,
|
| 63 |
+
order: bool = False,
|
| 64 |
+
kw_only: bool = False,
|
| 65 |
+
repr_omit_defaults: bool = False,
|
| 66 |
+
array_like: bool = False,
|
| 67 |
+
gc: bool = True,
|
| 68 |
+
weakref: bool = False,
|
| 69 |
+
dict: bool = False,
|
| 70 |
+
cache_hash: bool = False,
|
| 71 |
+
) -> None: ...
|
| 72 |
+
def __rich_repr__(
|
| 73 |
+
self,
|
| 74 |
+
) -> Iterable[Union[Any, Tuple[Any], Tuple[str, Any], Tuple[str, Any, Any]]]: ...
|
| 75 |
+
|
| 76 |
+
def defstruct(
|
| 77 |
+
name: str,
|
| 78 |
+
fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Any]]],
|
| 79 |
+
*,
|
| 80 |
+
bases: Optional[Tuple[Type[Struct], ...]] = None,
|
| 81 |
+
module: Optional[str] = None,
|
| 82 |
+
namespace: Optional[Dict[str, Any]] = None,
|
| 83 |
+
tag: Union[None, bool, str, int, Callable[[str], Union[str, int]]] = None,
|
| 84 |
+
tag_field: Union[None, str] = None,
|
| 85 |
+
rename: Union[
|
| 86 |
+
None,
|
| 87 |
+
Literal["lower", "upper", "camel", "pascal", "kebab"],
|
| 88 |
+
Callable[[str], Optional[str]],
|
| 89 |
+
Mapping[str, str],
|
| 90 |
+
] = None,
|
| 91 |
+
omit_defaults: bool = False,
|
| 92 |
+
forbid_unknown_fields: bool = False,
|
| 93 |
+
frozen: bool = False,
|
| 94 |
+
eq: bool = True,
|
| 95 |
+
order: bool = False,
|
| 96 |
+
kw_only: bool = False,
|
| 97 |
+
repr_omit_defaults: bool = False,
|
| 98 |
+
array_like: bool = False,
|
| 99 |
+
gc: bool = True,
|
| 100 |
+
weakref: bool = False,
|
| 101 |
+
dict: bool = False,
|
| 102 |
+
cache_hash: bool = False,
|
| 103 |
+
) -> Type[Struct]: ...
|
| 104 |
+
|
| 105 |
+
# Lie and say `Raw` is a subclass of `bytes`, so mypy will accept it in most
|
| 106 |
+
# places where an object that implements the buffer protocol is valid
|
| 107 |
+
class Raw(bytes):
|
| 108 |
+
@overload
|
| 109 |
+
def __new__(cls) -> "Raw": ...
|
| 110 |
+
@overload
|
| 111 |
+
def __new__(cls, msg: Union[Buffer, str]) -> "Raw": ...
|
| 112 |
+
def copy(self) -> "Raw": ...
|
| 113 |
+
|
| 114 |
+
class Meta:
|
| 115 |
+
def __init__(
|
| 116 |
+
self,
|
| 117 |
+
*,
|
| 118 |
+
gt: Union[int, float, None] = None,
|
| 119 |
+
ge: Union[int, float, None] = None,
|
| 120 |
+
lt: Union[int, float, None] = None,
|
| 121 |
+
le: Union[int, float, None] = None,
|
| 122 |
+
multiple_of: Union[int, float, None] = None,
|
| 123 |
+
pattern: Union[str, None] = None,
|
| 124 |
+
min_length: Union[int, None] = None,
|
| 125 |
+
max_length: Union[int, None] = None,
|
| 126 |
+
tz: Union[bool, None] = None,
|
| 127 |
+
title: Union[str, None] = None,
|
| 128 |
+
description: Union[str, None] = None,
|
| 129 |
+
examples: Union[list, None] = None,
|
| 130 |
+
extra_json_schema: Union[dict, None] = None,
|
| 131 |
+
extra: Union[dict, None] = None,
|
| 132 |
+
): ...
|
| 133 |
+
gt: Final[Union[int, float, None]]
|
| 134 |
+
ge: Final[Union[int, float, None]]
|
| 135 |
+
lt: Final[Union[int, float, None]]
|
| 136 |
+
le: Final[Union[int, float, None]]
|
| 137 |
+
multiple_of: Final[Union[int, float, None]]
|
| 138 |
+
pattern: Final[Union[str, None]]
|
| 139 |
+
min_length: Final[Union[int, None]]
|
| 140 |
+
max_length: Final[Union[int, None]]
|
| 141 |
+
tz: Final[Union[int, None]]
|
| 142 |
+
title: Final[Union[str, None]]
|
| 143 |
+
description: Final[Union[str, None]]
|
| 144 |
+
examples: Final[Union[list, None]]
|
| 145 |
+
extra_json_schema: Final[Union[dict, None]]
|
| 146 |
+
extra: Final[Union[dict, None]]
|
| 147 |
+
def __rich_repr__(self) -> Iterable[Tuple[str, Any]]: ...
|
| 148 |
+
|
| 149 |
+
def to_builtins(
|
| 150 |
+
obj: Any,
|
| 151 |
+
*,
|
| 152 |
+
str_keys: bool = False,
|
| 153 |
+
builtin_types: Union[Iterable[type], None] = None,
|
| 154 |
+
enc_hook: Optional[Callable[[Any], Any]] = None,
|
| 155 |
+
order: Literal[None, "deterministic", "sorted"] = None,
|
| 156 |
+
) -> Any: ...
|
| 157 |
+
@overload
|
| 158 |
+
def convert(
|
| 159 |
+
obj: Any,
|
| 160 |
+
type: Type[T],
|
| 161 |
+
*,
|
| 162 |
+
strict: bool = True,
|
| 163 |
+
from_attributes: bool = False,
|
| 164 |
+
dec_hook: Optional[Callable[[type, Any], Any]] = None,
|
| 165 |
+
builtin_types: Union[Iterable[type], None] = None,
|
| 166 |
+
str_keys: bool = False,
|
| 167 |
+
) -> T: ...
|
| 168 |
+
@overload
|
| 169 |
+
def convert(
|
| 170 |
+
obj: Any,
|
| 171 |
+
type: Any,
|
| 172 |
+
*,
|
| 173 |
+
strict: bool = True,
|
| 174 |
+
from_attributes: bool = False,
|
| 175 |
+
dec_hook: Optional[Callable[[type, Any], Any]] = None,
|
| 176 |
+
builtin_types: Union[Iterable[type], None] = None,
|
| 177 |
+
str_keys: bool = False,
|
| 178 |
+
) -> Any: ...
|
| 179 |
+
|
| 180 |
+
class MsgspecError(Exception): ...
|
| 181 |
+
class EncodeError(MsgspecError): ...
|
| 182 |
+
class DecodeError(MsgspecError): ...
|
| 183 |
+
class ValidationError(DecodeError): ...
|
| 184 |
+
|
| 185 |
+
__version__: str
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (1.32 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/_json_schema.cpython-311.pyc
ADDED
|
Binary file (23.5 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/_utils.cpython-311.pyc
ADDED
|
Binary file (13.3 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/_version.cpython-311.pyc
ADDED
|
Binary file (586 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/inspect.cpython-311.pyc
ADDED
|
Binary file (40.2 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/json.cpython-311.pyc
ADDED
|
Binary file (508 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/msgpack.cpython-311.pyc
ADDED
|
Binary file (416 Bytes). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/structs.cpython-311.pyc
ADDED
|
Binary file (4.46 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/toml.cpython-311.pyc
ADDED
|
Binary file (7.25 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/__pycache__/yaml.cpython-311.pyc
ADDED
|
Binary file (6.85 kB). View file
|
|
|
.venv/lib/python3.11/site-packages/msgspec/_json_schema.py
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
import textwrap
|
| 5 |
+
from collections.abc import Iterable
|
| 6 |
+
from typing import Any, Optional, Callable
|
| 7 |
+
|
| 8 |
+
from . import inspect as mi, to_builtins
|
| 9 |
+
|
| 10 |
+
__all__ = ("schema", "schema_components")
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def schema(
|
| 14 |
+
type: Any, *, schema_hook: Optional[Callable[[type], dict[str, Any]]] = None
|
| 15 |
+
) -> dict[str, Any]:
|
| 16 |
+
"""Generate a JSON Schema for a given type.
|
| 17 |
+
|
| 18 |
+
Any schemas for (potentially) shared components are extracted and stored in
|
| 19 |
+
a top-level ``"$defs"`` field.
|
| 20 |
+
|
| 21 |
+
If you want to generate schemas for multiple types, or to have more control
|
| 22 |
+
over the generated schema you may want to use ``schema_components`` instead.
|
| 23 |
+
|
| 24 |
+
Parameters
|
| 25 |
+
----------
|
| 26 |
+
type : type
|
| 27 |
+
The type to generate the schema for.
|
| 28 |
+
schema_hook : callable, optional
|
| 29 |
+
An optional callback to use for generating JSON schemas of custom
|
| 30 |
+
types. Will be called with the custom type, and should return a dict
|
| 31 |
+
representation of the JSON schema for that type.
|
| 32 |
+
|
| 33 |
+
Returns
|
| 34 |
+
-------
|
| 35 |
+
schema : dict
|
| 36 |
+
The generated JSON Schema.
|
| 37 |
+
|
| 38 |
+
See Also
|
| 39 |
+
--------
|
| 40 |
+
schema_components
|
| 41 |
+
"""
|
| 42 |
+
(out,), components = schema_components((type,), schema_hook=schema_hook)
|
| 43 |
+
if components:
|
| 44 |
+
out["$defs"] = components
|
| 45 |
+
return out
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def schema_components(
|
| 49 |
+
types: Iterable[Any],
|
| 50 |
+
*,
|
| 51 |
+
schema_hook: Optional[Callable[[type], dict[str, Any]]] = None,
|
| 52 |
+
ref_template: str = "#/$defs/{name}",
|
| 53 |
+
) -> tuple[tuple[dict[str, Any], ...], dict[str, Any]]:
|
| 54 |
+
"""Generate JSON Schemas for one or more types.
|
| 55 |
+
|
| 56 |
+
Any schemas for (potentially) shared components are extracted and returned
|
| 57 |
+
in a separate ``components`` dict.
|
| 58 |
+
|
| 59 |
+
Parameters
|
| 60 |
+
----------
|
| 61 |
+
types : Iterable[type]
|
| 62 |
+
An iterable of one or more types to generate schemas for.
|
| 63 |
+
schema_hook : callable, optional
|
| 64 |
+
An optional callback to use for generating JSON schemas of custom
|
| 65 |
+
types. Will be called with the custom type, and should return a dict
|
| 66 |
+
representation of the JSON schema for that type.
|
| 67 |
+
ref_template : str, optional
|
| 68 |
+
A template to use when generating ``"$ref"`` fields. This template is
|
| 69 |
+
formatted with the type name as ``template.format(name=name)``. This
|
| 70 |
+
can be useful if you intend to store the ``components`` mapping
|
| 71 |
+
somewhere other than a top-level ``"$defs"`` field. For example, you
|
| 72 |
+
might use ``ref_template="#/components/{name}"`` if generating an
|
| 73 |
+
OpenAPI schema.
|
| 74 |
+
|
| 75 |
+
Returns
|
| 76 |
+
-------
|
| 77 |
+
schemas : tuple[dict]
|
| 78 |
+
A tuple of JSON Schemas, one for each type in ``types``.
|
| 79 |
+
components : dict
|
| 80 |
+
A mapping of name to schema for any shared components used by
|
| 81 |
+
``schemas``.
|
| 82 |
+
|
| 83 |
+
See Also
|
| 84 |
+
--------
|
| 85 |
+
schema
|
| 86 |
+
"""
|
| 87 |
+
type_infos = mi.multi_type_info(types)
|
| 88 |
+
|
| 89 |
+
component_types = _collect_component_types(type_infos)
|
| 90 |
+
|
| 91 |
+
name_map = _build_name_map(component_types)
|
| 92 |
+
|
| 93 |
+
gen = _SchemaGenerator(name_map, schema_hook, ref_template)
|
| 94 |
+
|
| 95 |
+
schemas = tuple(gen.to_schema(t) for t in type_infos)
|
| 96 |
+
|
| 97 |
+
components = {
|
| 98 |
+
name_map[cls]: gen.to_schema(t, False) for cls, t in component_types.items()
|
| 99 |
+
}
|
| 100 |
+
return schemas, components
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def _collect_component_types(type_infos: Iterable[mi.Type]) -> dict[Any, mi.Type]:
|
| 104 |
+
"""Find all types in the type tree that are "nameable" and worthy of being
|
| 105 |
+
extracted out into a shared top-level components mapping.
|
| 106 |
+
|
| 107 |
+
Currently this looks for Struct, Dataclass, NamedTuple, TypedDict, and Enum
|
| 108 |
+
types.
|
| 109 |
+
"""
|
| 110 |
+
components = {}
|
| 111 |
+
|
| 112 |
+
def collect(t):
|
| 113 |
+
if isinstance(
|
| 114 |
+
t, (mi.StructType, mi.TypedDictType, mi.DataclassType, mi.NamedTupleType)
|
| 115 |
+
):
|
| 116 |
+
if t.cls not in components:
|
| 117 |
+
components[t.cls] = t
|
| 118 |
+
for f in t.fields:
|
| 119 |
+
collect(f.type)
|
| 120 |
+
elif isinstance(t, mi.EnumType):
|
| 121 |
+
components[t.cls] = t
|
| 122 |
+
elif isinstance(t, mi.Metadata):
|
| 123 |
+
collect(t.type)
|
| 124 |
+
elif isinstance(t, mi.CollectionType):
|
| 125 |
+
collect(t.item_type)
|
| 126 |
+
elif isinstance(t, mi.TupleType):
|
| 127 |
+
for st in t.item_types:
|
| 128 |
+
collect(st)
|
| 129 |
+
elif isinstance(t, mi.DictType):
|
| 130 |
+
collect(t.key_type)
|
| 131 |
+
collect(t.value_type)
|
| 132 |
+
elif isinstance(t, mi.UnionType):
|
| 133 |
+
for st in t.types:
|
| 134 |
+
collect(st)
|
| 135 |
+
|
| 136 |
+
for t in type_infos:
|
| 137 |
+
collect(t)
|
| 138 |
+
|
| 139 |
+
return components
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def _type_repr(obj):
|
| 143 |
+
return obj.__name__ if isinstance(obj, type) else repr(obj)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
def _get_class_name(cls: Any) -> str:
|
| 147 |
+
if hasattr(cls, "__origin__"):
|
| 148 |
+
name = cls.__origin__.__name__
|
| 149 |
+
args = ", ".join(_type_repr(a) for a in cls.__args__)
|
| 150 |
+
return f"{name}[{args}]"
|
| 151 |
+
return cls.__name__
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def _get_doc(t: mi.Type) -> str:
|
| 155 |
+
assert hasattr(t, "cls")
|
| 156 |
+
cls = getattr(t.cls, "__origin__", t.cls)
|
| 157 |
+
doc = getattr(cls, "__doc__", "")
|
| 158 |
+
if not doc:
|
| 159 |
+
return ""
|
| 160 |
+
doc = textwrap.dedent(doc).strip("\r\n")
|
| 161 |
+
if isinstance(t, mi.EnumType):
|
| 162 |
+
if doc == "An enumeration.":
|
| 163 |
+
return ""
|
| 164 |
+
elif isinstance(t, (mi.NamedTupleType, mi.DataclassType)):
|
| 165 |
+
if doc.startswith(f"{cls.__name__}(") and doc.endswith(")"):
|
| 166 |
+
return ""
|
| 167 |
+
return doc
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _build_name_map(component_types: dict[Any, mi.Type]) -> dict[Any, str]:
|
| 171 |
+
"""A mapping from nameable subcomponents to a generated name.
|
| 172 |
+
|
| 173 |
+
The generated name is usually a normalized version of the class name. In
|
| 174 |
+
the case of conflicts, the name will be expanded to also include the full
|
| 175 |
+
import path.
|
| 176 |
+
"""
|
| 177 |
+
|
| 178 |
+
def normalize(name):
|
| 179 |
+
return re.sub(r"[^a-zA-Z0-9.\-_]", "_", name)
|
| 180 |
+
|
| 181 |
+
def fullname(cls):
|
| 182 |
+
return normalize(f"{cls.__module__}.{cls.__qualname__}")
|
| 183 |
+
|
| 184 |
+
conflicts = set()
|
| 185 |
+
names: dict[str, Any] = {}
|
| 186 |
+
|
| 187 |
+
for cls in component_types:
|
| 188 |
+
name = normalize(_get_class_name(cls))
|
| 189 |
+
if name in names:
|
| 190 |
+
old = names.pop(name)
|
| 191 |
+
conflicts.add(name)
|
| 192 |
+
names[fullname(old)] = old
|
| 193 |
+
if name in conflicts:
|
| 194 |
+
names[fullname(cls)] = cls
|
| 195 |
+
else:
|
| 196 |
+
names[name] = cls
|
| 197 |
+
return {v: k for k, v in names.items()}
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
class _SchemaGenerator:
|
| 201 |
+
def __init__(
|
| 202 |
+
self,
|
| 203 |
+
name_map: dict[Any, str],
|
| 204 |
+
schema_hook: Optional[Callable[[type], dict[str, Any]]] = None,
|
| 205 |
+
ref_template: str = "#/$defs/{name}",
|
| 206 |
+
):
|
| 207 |
+
self.name_map = name_map
|
| 208 |
+
self.schema_hook = schema_hook
|
| 209 |
+
self.ref_template = ref_template
|
| 210 |
+
|
| 211 |
+
def to_schema(self, t: mi.Type, check_ref: bool = True) -> dict[str, Any]:
|
| 212 |
+
"""Converts a Type to a json-schema."""
|
| 213 |
+
schema: dict[str, Any] = {}
|
| 214 |
+
|
| 215 |
+
while isinstance(t, mi.Metadata):
|
| 216 |
+
schema = mi._merge_json(schema, t.extra_json_schema)
|
| 217 |
+
t = t.type
|
| 218 |
+
|
| 219 |
+
if check_ref and hasattr(t, "cls"):
|
| 220 |
+
if name := self.name_map.get(t.cls):
|
| 221 |
+
schema["$ref"] = self.ref_template.format(name=name)
|
| 222 |
+
return schema
|
| 223 |
+
|
| 224 |
+
if isinstance(t, (mi.AnyType, mi.RawType)):
|
| 225 |
+
pass
|
| 226 |
+
elif isinstance(t, mi.NoneType):
|
| 227 |
+
schema["type"] = "null"
|
| 228 |
+
elif isinstance(t, mi.BoolType):
|
| 229 |
+
schema["type"] = "boolean"
|
| 230 |
+
elif isinstance(t, (mi.IntType, mi.FloatType)):
|
| 231 |
+
schema["type"] = "integer" if isinstance(t, mi.IntType) else "number"
|
| 232 |
+
if t.ge is not None:
|
| 233 |
+
schema["minimum"] = t.ge
|
| 234 |
+
if t.gt is not None:
|
| 235 |
+
schema["exclusiveMinimum"] = t.gt
|
| 236 |
+
if t.le is not None:
|
| 237 |
+
schema["maximum"] = t.le
|
| 238 |
+
if t.lt is not None:
|
| 239 |
+
schema["exclusiveMaximum"] = t.lt
|
| 240 |
+
if t.multiple_of is not None:
|
| 241 |
+
schema["multipleOf"] = t.multiple_of
|
| 242 |
+
elif isinstance(t, mi.StrType):
|
| 243 |
+
schema["type"] = "string"
|
| 244 |
+
if t.max_length is not None:
|
| 245 |
+
schema["maxLength"] = t.max_length
|
| 246 |
+
if t.min_length is not None:
|
| 247 |
+
schema["minLength"] = t.min_length
|
| 248 |
+
if t.pattern is not None:
|
| 249 |
+
schema["pattern"] = t.pattern
|
| 250 |
+
elif isinstance(t, (mi.BytesType, mi.ByteArrayType, mi.MemoryViewType)):
|
| 251 |
+
schema["type"] = "string"
|
| 252 |
+
schema["contentEncoding"] = "base64"
|
| 253 |
+
if t.max_length is not None:
|
| 254 |
+
schema["maxLength"] = 4 * ((t.max_length + 2) // 3)
|
| 255 |
+
if t.min_length is not None:
|
| 256 |
+
schema["minLength"] = 4 * ((t.min_length + 2) // 3)
|
| 257 |
+
elif isinstance(t, mi.DateTimeType):
|
| 258 |
+
schema["type"] = "string"
|
| 259 |
+
if t.tz is True:
|
| 260 |
+
schema["format"] = "date-time"
|
| 261 |
+
elif isinstance(t, mi.TimeType):
|
| 262 |
+
schema["type"] = "string"
|
| 263 |
+
if t.tz is True:
|
| 264 |
+
schema["format"] = "time"
|
| 265 |
+
elif t.tz is False:
|
| 266 |
+
schema["format"] = "partial-time"
|
| 267 |
+
elif isinstance(t, mi.DateType):
|
| 268 |
+
schema["type"] = "string"
|
| 269 |
+
schema["format"] = "date"
|
| 270 |
+
elif isinstance(t, mi.TimeDeltaType):
|
| 271 |
+
schema["type"] = "string"
|
| 272 |
+
schema["format"] = "duration"
|
| 273 |
+
elif isinstance(t, mi.UUIDType):
|
| 274 |
+
schema["type"] = "string"
|
| 275 |
+
schema["format"] = "uuid"
|
| 276 |
+
elif isinstance(t, mi.DecimalType):
|
| 277 |
+
schema["type"] = "string"
|
| 278 |
+
schema["format"] = "decimal"
|
| 279 |
+
elif isinstance(t, mi.CollectionType):
|
| 280 |
+
schema["type"] = "array"
|
| 281 |
+
if not isinstance(t.item_type, mi.AnyType):
|
| 282 |
+
schema["items"] = self.to_schema(t.item_type)
|
| 283 |
+
if t.max_length is not None:
|
| 284 |
+
schema["maxItems"] = t.max_length
|
| 285 |
+
if t.min_length is not None:
|
| 286 |
+
schema["minItems"] = t.min_length
|
| 287 |
+
elif isinstance(t, mi.TupleType):
|
| 288 |
+
schema["type"] = "array"
|
| 289 |
+
schema["minItems"] = schema["maxItems"] = len(t.item_types)
|
| 290 |
+
if t.item_types:
|
| 291 |
+
schema["prefixItems"] = [self.to_schema(i) for i in t.item_types]
|
| 292 |
+
schema["items"] = False
|
| 293 |
+
elif isinstance(t, mi.DictType):
|
| 294 |
+
schema["type"] = "object"
|
| 295 |
+
# If there are restrictions on the keys, specify them as propertyNames
|
| 296 |
+
if isinstance(key_type := t.key_type, mi.StrType):
|
| 297 |
+
property_names: dict[str, Any] = {}
|
| 298 |
+
if key_type.min_length is not None:
|
| 299 |
+
property_names["minLength"] = key_type.min_length
|
| 300 |
+
if key_type.max_length is not None:
|
| 301 |
+
property_names["maxLength"] = key_type.max_length
|
| 302 |
+
if key_type.pattern is not None:
|
| 303 |
+
property_names["pattern"] = key_type.pattern
|
| 304 |
+
if property_names:
|
| 305 |
+
schema["propertyNames"] = property_names
|
| 306 |
+
if not isinstance(t.value_type, mi.AnyType):
|
| 307 |
+
schema["additionalProperties"] = self.to_schema(t.value_type)
|
| 308 |
+
if t.max_length is not None:
|
| 309 |
+
schema["maxProperties"] = t.max_length
|
| 310 |
+
if t.min_length is not None:
|
| 311 |
+
schema["minProperties"] = t.min_length
|
| 312 |
+
elif isinstance(t, mi.UnionType):
|
| 313 |
+
structs = {}
|
| 314 |
+
other = []
|
| 315 |
+
tag_field = None
|
| 316 |
+
for subtype in t.types:
|
| 317 |
+
real_type = subtype
|
| 318 |
+
while isinstance(real_type, mi.Metadata):
|
| 319 |
+
real_type = real_type.type
|
| 320 |
+
if isinstance(real_type, mi.StructType) and not real_type.array_like:
|
| 321 |
+
tag_field = real_type.tag_field
|
| 322 |
+
structs[real_type.tag] = real_type
|
| 323 |
+
else:
|
| 324 |
+
other.append(subtype)
|
| 325 |
+
|
| 326 |
+
options = [self.to_schema(a) for a in other]
|
| 327 |
+
|
| 328 |
+
if len(structs) >= 2:
|
| 329 |
+
mapping = {
|
| 330 |
+
k: self.ref_template.format(name=self.name_map[v.cls])
|
| 331 |
+
for k, v in structs.items()
|
| 332 |
+
}
|
| 333 |
+
struct_schema = {
|
| 334 |
+
"anyOf": [self.to_schema(v) for v in structs.values()],
|
| 335 |
+
"discriminator": {"propertyName": tag_field, "mapping": mapping},
|
| 336 |
+
}
|
| 337 |
+
if options:
|
| 338 |
+
options.append(struct_schema)
|
| 339 |
+
schema["anyOf"] = options
|
| 340 |
+
else:
|
| 341 |
+
schema.update(struct_schema)
|
| 342 |
+
elif len(structs) == 1:
|
| 343 |
+
_, subtype = structs.popitem()
|
| 344 |
+
options.append(self.to_schema(subtype))
|
| 345 |
+
schema["anyOf"] = options
|
| 346 |
+
else:
|
| 347 |
+
schema["anyOf"] = options
|
| 348 |
+
elif isinstance(t, mi.LiteralType):
|
| 349 |
+
schema["enum"] = sorted(t.values)
|
| 350 |
+
elif isinstance(t, mi.EnumType):
|
| 351 |
+
schema.setdefault("title", t.cls.__name__)
|
| 352 |
+
if doc := _get_doc(t):
|
| 353 |
+
schema.setdefault("description", doc)
|
| 354 |
+
schema["enum"] = sorted(e.value for e in t.cls)
|
| 355 |
+
elif isinstance(t, mi.StructType):
|
| 356 |
+
schema.setdefault("title", _get_class_name(t.cls))
|
| 357 |
+
if doc := _get_doc(t):
|
| 358 |
+
schema.setdefault("description", doc)
|
| 359 |
+
required = []
|
| 360 |
+
names = []
|
| 361 |
+
fields = []
|
| 362 |
+
|
| 363 |
+
if t.tag_field is not None:
|
| 364 |
+
required.append(t.tag_field)
|
| 365 |
+
names.append(t.tag_field)
|
| 366 |
+
fields.append({"enum": [t.tag]})
|
| 367 |
+
|
| 368 |
+
for field in t.fields:
|
| 369 |
+
field_schema = self.to_schema(field.type)
|
| 370 |
+
if field.required:
|
| 371 |
+
required.append(field.encode_name)
|
| 372 |
+
elif field.default is not mi.NODEFAULT:
|
| 373 |
+
field_schema["default"] = to_builtins(field.default, str_keys=True)
|
| 374 |
+
elif field.default_factory in (list, dict, set, bytearray):
|
| 375 |
+
field_schema["default"] = field.default_factory()
|
| 376 |
+
names.append(field.encode_name)
|
| 377 |
+
fields.append(field_schema)
|
| 378 |
+
|
| 379 |
+
if t.array_like:
|
| 380 |
+
n_trailing_defaults = 0
|
| 381 |
+
for n_trailing_defaults, f in enumerate(reversed(t.fields)):
|
| 382 |
+
if f.required:
|
| 383 |
+
break
|
| 384 |
+
schema["type"] = "array"
|
| 385 |
+
schema["prefixItems"] = fields
|
| 386 |
+
schema["minItems"] = len(fields) - n_trailing_defaults
|
| 387 |
+
if t.forbid_unknown_fields:
|
| 388 |
+
schema["maxItems"] = len(fields)
|
| 389 |
+
else:
|
| 390 |
+
schema["type"] = "object"
|
| 391 |
+
schema["properties"] = dict(zip(names, fields))
|
| 392 |
+
schema["required"] = required
|
| 393 |
+
if t.forbid_unknown_fields:
|
| 394 |
+
schema["additionalProperties"] = False
|
| 395 |
+
elif isinstance(t, (mi.TypedDictType, mi.DataclassType, mi.NamedTupleType)):
|
| 396 |
+
schema.setdefault("title", _get_class_name(t.cls))
|
| 397 |
+
if doc := _get_doc(t):
|
| 398 |
+
schema.setdefault("description", doc)
|
| 399 |
+
names = []
|
| 400 |
+
fields = []
|
| 401 |
+
required = []
|
| 402 |
+
for field in t.fields:
|
| 403 |
+
field_schema = self.to_schema(field.type)
|
| 404 |
+
if field.required:
|
| 405 |
+
required.append(field.encode_name)
|
| 406 |
+
elif field.default is not mi.NODEFAULT:
|
| 407 |
+
field_schema["default"] = to_builtins(field.default, str_keys=True)
|
| 408 |
+
names.append(field.encode_name)
|
| 409 |
+
fields.append(field_schema)
|
| 410 |
+
if isinstance(t, mi.NamedTupleType):
|
| 411 |
+
schema["type"] = "array"
|
| 412 |
+
schema["prefixItems"] = fields
|
| 413 |
+
schema["minItems"] = len(required)
|
| 414 |
+
schema["maxItems"] = len(fields)
|
| 415 |
+
else:
|
| 416 |
+
schema["type"] = "object"
|
| 417 |
+
schema["properties"] = dict(zip(names, fields))
|
| 418 |
+
schema["required"] = required
|
| 419 |
+
elif isinstance(t, mi.ExtType):
|
| 420 |
+
raise TypeError("json-schema doesn't support msgpack Ext types")
|
| 421 |
+
elif isinstance(t, mi.CustomType):
|
| 422 |
+
if self.schema_hook:
|
| 423 |
+
try:
|
| 424 |
+
schema = mi._merge_json(self.schema_hook(t.cls), schema)
|
| 425 |
+
except NotImplementedError:
|
| 426 |
+
pass
|
| 427 |
+
if not schema:
|
| 428 |
+
raise TypeError(
|
| 429 |
+
"Generating JSON schema for custom types requires either:\n"
|
| 430 |
+
"- specifying a `schema_hook`\n"
|
| 431 |
+
"- annotating the type with `Meta(extra_json_schema=...)`\n"
|
| 432 |
+
"\n"
|
| 433 |
+
f"type {t.cls!r} is not supported"
|
| 434 |
+
)
|
| 435 |
+
else:
|
| 436 |
+
# This should be unreachable
|
| 437 |
+
raise TypeError(f"json-schema doesn't support type {t!r}")
|
| 438 |
+
|
| 439 |
+
return schema
|
.venv/lib/python3.11/site-packages/msgspec/_utils.py
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# type: ignore
|
| 2 |
+
import collections
|
| 3 |
+
import sys
|
| 4 |
+
import typing
|
| 5 |
+
|
| 6 |
+
from typing import _AnnotatedAlias # noqa: F401
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
from typing_extensions import get_type_hints as _get_type_hints
|
| 10 |
+
except Exception:
|
| 11 |
+
from typing import get_type_hints as _get_type_hints
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
from typing_extensions import NotRequired, Required
|
| 15 |
+
except Exception:
|
| 16 |
+
try:
|
| 17 |
+
from typing import NotRequired, Required
|
| 18 |
+
except Exception:
|
| 19 |
+
Required = NotRequired = None
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def get_type_hints(obj):
|
| 23 |
+
return _get_type_hints(obj, include_extras=True)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# The `is_class` argument was new in 3.11, but was backported to 3.9 and 3.10.
|
| 27 |
+
# It's _likely_ to be available for 3.9/3.10, but may not be. Easiest way to
|
| 28 |
+
# check is to try it and see. This check can be removed when we drop support
|
| 29 |
+
# for Python 3.10.
|
| 30 |
+
try:
|
| 31 |
+
typing.ForwardRef("Foo", is_class=True)
|
| 32 |
+
except TypeError:
|
| 33 |
+
|
| 34 |
+
def _forward_ref(value):
|
| 35 |
+
return typing.ForwardRef(value, is_argument=False)
|
| 36 |
+
|
| 37 |
+
else:
|
| 38 |
+
|
| 39 |
+
def _forward_ref(value):
|
| 40 |
+
return typing.ForwardRef(value, is_argument=False, is_class=True)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# Python 3.13 adds a new mandatory type_params kwarg to _eval_type
|
| 44 |
+
if sys.version_info >= (3, 13):
|
| 45 |
+
|
| 46 |
+
def _eval_type(t, globalns, localns):
|
| 47 |
+
return typing._eval_type(t, globalns, localns, ())
|
| 48 |
+
elif sys.version_info < (3, 10):
|
| 49 |
+
|
| 50 |
+
def _eval_type(t, globalns, localns):
|
| 51 |
+
try:
|
| 52 |
+
return typing._eval_type(t, globalns, localns)
|
| 53 |
+
except TypeError as e:
|
| 54 |
+
try:
|
| 55 |
+
from eval_type_backport import eval_type_backport
|
| 56 |
+
except ImportError:
|
| 57 |
+
raise TypeError(
|
| 58 |
+
f"Unable to evaluate type annotation {t.__forward_arg__!r}. If you are making use "
|
| 59 |
+
"of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting "
|
| 60 |
+
"since Python 3.9), you should either replace the use of new syntax with the existing "
|
| 61 |
+
"`typing` constructs or install the `eval_type_backport` package."
|
| 62 |
+
) from e
|
| 63 |
+
|
| 64 |
+
return eval_type_backport(
|
| 65 |
+
t,
|
| 66 |
+
globalns,
|
| 67 |
+
localns,
|
| 68 |
+
try_default=False,
|
| 69 |
+
)
|
| 70 |
+
else:
|
| 71 |
+
_eval_type = typing._eval_type
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def _apply_params(obj, mapping):
|
| 75 |
+
if isinstance(obj, typing.TypeVar):
|
| 76 |
+
return mapping.get(obj, obj)
|
| 77 |
+
|
| 78 |
+
try:
|
| 79 |
+
parameters = tuple(obj.__parameters__)
|
| 80 |
+
except Exception:
|
| 81 |
+
# Not parameterized or __parameters__ is invalid, ignore
|
| 82 |
+
return obj
|
| 83 |
+
|
| 84 |
+
if not parameters:
|
| 85 |
+
# Not parametrized
|
| 86 |
+
return obj
|
| 87 |
+
|
| 88 |
+
# Parametrized
|
| 89 |
+
args = tuple(mapping.get(p, p) for p in parameters)
|
| 90 |
+
return obj[args]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def _get_class_mro_and_typevar_mappings(obj):
|
| 94 |
+
mapping = {}
|
| 95 |
+
|
| 96 |
+
if isinstance(obj, type):
|
| 97 |
+
cls = obj
|
| 98 |
+
else:
|
| 99 |
+
cls = obj.__origin__
|
| 100 |
+
|
| 101 |
+
def inner(c, scope):
|
| 102 |
+
if isinstance(c, type):
|
| 103 |
+
cls = c
|
| 104 |
+
new_scope = {}
|
| 105 |
+
else:
|
| 106 |
+
cls = getattr(c, "__origin__", None)
|
| 107 |
+
if cls in (None, object, typing.Generic) or cls in mapping:
|
| 108 |
+
return
|
| 109 |
+
params = cls.__parameters__
|
| 110 |
+
args = tuple(_apply_params(a, scope) for a in c.__args__)
|
| 111 |
+
assert len(params) == len(args)
|
| 112 |
+
mapping[cls] = new_scope = dict(zip(params, args))
|
| 113 |
+
|
| 114 |
+
if issubclass(cls, typing.Generic):
|
| 115 |
+
bases = getattr(cls, "__orig_bases__", cls.__bases__)
|
| 116 |
+
for b in bases:
|
| 117 |
+
inner(b, new_scope)
|
| 118 |
+
|
| 119 |
+
inner(obj, {})
|
| 120 |
+
return cls.__mro__, mapping
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def get_class_annotations(obj):
|
| 124 |
+
"""Get the annotations for a class.
|
| 125 |
+
|
| 126 |
+
This is similar to ``typing.get_type_hints``, except:
|
| 127 |
+
|
| 128 |
+
- We maintain it
|
| 129 |
+
- It leaves extras like ``Annotated``/``ClassVar`` alone
|
| 130 |
+
- It resolves any parametrized generics in the class mro. The returned
|
| 131 |
+
mapping may still include ``TypeVar`` values, but those should be treated
|
| 132 |
+
as their unparametrized variants (i.e. equal to ``Any`` for the common case).
|
| 133 |
+
|
| 134 |
+
Note that this function doesn't check that Generic types are being used
|
| 135 |
+
properly - invalid uses of `Generic` may slip through without complaint.
|
| 136 |
+
|
| 137 |
+
The assumption here is that the user is making use of a static analysis
|
| 138 |
+
tool like ``mypy``/``pyright`` already, which would catch misuse of these
|
| 139 |
+
APIs.
|
| 140 |
+
"""
|
| 141 |
+
hints = {}
|
| 142 |
+
mro, typevar_mappings = _get_class_mro_and_typevar_mappings(obj)
|
| 143 |
+
|
| 144 |
+
for cls in mro:
|
| 145 |
+
if cls in (typing.Generic, object):
|
| 146 |
+
continue
|
| 147 |
+
|
| 148 |
+
mapping = typevar_mappings.get(cls)
|
| 149 |
+
cls_locals = dict(vars(cls))
|
| 150 |
+
cls_globals = getattr(sys.modules.get(cls.__module__, None), "__dict__", {})
|
| 151 |
+
|
| 152 |
+
ann = cls.__dict__.get("__annotations__", {})
|
| 153 |
+
for name, value in ann.items():
|
| 154 |
+
if name in hints:
|
| 155 |
+
continue
|
| 156 |
+
if value is None:
|
| 157 |
+
value = type(None)
|
| 158 |
+
elif isinstance(value, str):
|
| 159 |
+
value = _forward_ref(value)
|
| 160 |
+
value = _eval_type(value, cls_locals, cls_globals)
|
| 161 |
+
if mapping is not None:
|
| 162 |
+
value = _apply_params(value, mapping)
|
| 163 |
+
hints[name] = value
|
| 164 |
+
return hints
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
# A mapping from a type annotation (or annotation __origin__) to the concrete
|
| 168 |
+
# python type that msgspec will use when decoding. THIS IS PRIVATE FOR A
|
| 169 |
+
# REASON. DON'T MUCK WITH THIS.
|
| 170 |
+
_CONCRETE_TYPES = {
|
| 171 |
+
list: list,
|
| 172 |
+
tuple: tuple,
|
| 173 |
+
set: set,
|
| 174 |
+
frozenset: frozenset,
|
| 175 |
+
dict: dict,
|
| 176 |
+
typing.List: list,
|
| 177 |
+
typing.Tuple: tuple,
|
| 178 |
+
typing.Set: set,
|
| 179 |
+
typing.FrozenSet: frozenset,
|
| 180 |
+
typing.Dict: dict,
|
| 181 |
+
typing.Collection: list,
|
| 182 |
+
typing.MutableSequence: list,
|
| 183 |
+
typing.Sequence: list,
|
| 184 |
+
typing.MutableMapping: dict,
|
| 185 |
+
typing.Mapping: dict,
|
| 186 |
+
typing.MutableSet: set,
|
| 187 |
+
typing.AbstractSet: set,
|
| 188 |
+
collections.abc.Collection: list,
|
| 189 |
+
collections.abc.MutableSequence: list,
|
| 190 |
+
collections.abc.Sequence: list,
|
| 191 |
+
collections.abc.MutableSet: set,
|
| 192 |
+
collections.abc.Set: set,
|
| 193 |
+
collections.abc.MutableMapping: dict,
|
| 194 |
+
collections.abc.Mapping: dict,
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def get_typeddict_info(obj):
|
| 199 |
+
if isinstance(obj, type):
|
| 200 |
+
cls = obj
|
| 201 |
+
else:
|
| 202 |
+
cls = obj.__origin__
|
| 203 |
+
|
| 204 |
+
raw_hints = get_class_annotations(obj)
|
| 205 |
+
|
| 206 |
+
if hasattr(cls, "__required_keys__"):
|
| 207 |
+
required = set(cls.__required_keys__)
|
| 208 |
+
elif cls.__total__:
|
| 209 |
+
required = set(raw_hints)
|
| 210 |
+
else:
|
| 211 |
+
required = set()
|
| 212 |
+
|
| 213 |
+
# Both `typing.TypedDict` and `typing_extensions.TypedDict` have a bug
|
| 214 |
+
# where `Required`/`NotRequired` aren't properly detected at runtime when
|
| 215 |
+
# `__future__.annotations` is enabled, meaning the `__required_keys__`
|
| 216 |
+
# isn't correct. This code block works around this issue by amending the
|
| 217 |
+
# set of required keys as needed, while also stripping off any
|
| 218 |
+
# `Required`/`NotRequired` wrappers.
|
| 219 |
+
hints = {}
|
| 220 |
+
for k, v in raw_hints.items():
|
| 221 |
+
origin = getattr(v, "__origin__", False)
|
| 222 |
+
if origin is Required:
|
| 223 |
+
required.add(k)
|
| 224 |
+
hints[k] = v.__args__[0]
|
| 225 |
+
elif origin is NotRequired:
|
| 226 |
+
required.discard(k)
|
| 227 |
+
hints[k] = v.__args__[0]
|
| 228 |
+
else:
|
| 229 |
+
hints[k] = v
|
| 230 |
+
return hints, required
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def get_dataclass_info(obj):
|
| 234 |
+
if isinstance(obj, type):
|
| 235 |
+
cls = obj
|
| 236 |
+
else:
|
| 237 |
+
cls = obj.__origin__
|
| 238 |
+
hints = get_class_annotations(obj)
|
| 239 |
+
required = []
|
| 240 |
+
optional = []
|
| 241 |
+
defaults = []
|
| 242 |
+
|
| 243 |
+
if hasattr(cls, "__dataclass_fields__"):
|
| 244 |
+
from dataclasses import _FIELD, _FIELD_INITVAR, MISSING
|
| 245 |
+
|
| 246 |
+
for field in cls.__dataclass_fields__.values():
|
| 247 |
+
if field._field_type is not _FIELD:
|
| 248 |
+
if field._field_type is _FIELD_INITVAR:
|
| 249 |
+
raise TypeError(
|
| 250 |
+
"dataclasses with `InitVar` fields are not supported"
|
| 251 |
+
)
|
| 252 |
+
continue
|
| 253 |
+
name = field.name
|
| 254 |
+
typ = hints[name]
|
| 255 |
+
if field.default is not MISSING:
|
| 256 |
+
defaults.append(field.default)
|
| 257 |
+
optional.append((name, typ, False))
|
| 258 |
+
elif field.default_factory is not MISSING:
|
| 259 |
+
defaults.append(field.default_factory)
|
| 260 |
+
optional.append((name, typ, True))
|
| 261 |
+
else:
|
| 262 |
+
required.append((name, typ, False))
|
| 263 |
+
|
| 264 |
+
required.extend(optional)
|
| 265 |
+
|
| 266 |
+
pre_init = None
|
| 267 |
+
post_init = getattr(cls, "__post_init__", None)
|
| 268 |
+
else:
|
| 269 |
+
from attrs import NOTHING, Factory
|
| 270 |
+
|
| 271 |
+
fields_with_validators = []
|
| 272 |
+
|
| 273 |
+
for field in cls.__attrs_attrs__:
|
| 274 |
+
name = field.name
|
| 275 |
+
typ = hints[name]
|
| 276 |
+
default = field.default
|
| 277 |
+
if default is not NOTHING:
|
| 278 |
+
if isinstance(default, Factory):
|
| 279 |
+
if default.takes_self:
|
| 280 |
+
raise NotImplementedError(
|
| 281 |
+
"Support for default factories with `takes_self=True` "
|
| 282 |
+
"is not implemented. File a GitHub issue if you need "
|
| 283 |
+
"this feature!"
|
| 284 |
+
)
|
| 285 |
+
defaults.append(default.factory)
|
| 286 |
+
optional.append((name, typ, True))
|
| 287 |
+
else:
|
| 288 |
+
defaults.append(default)
|
| 289 |
+
optional.append((name, typ, False))
|
| 290 |
+
else:
|
| 291 |
+
required.append((name, typ, False))
|
| 292 |
+
|
| 293 |
+
if field.validator is not None:
|
| 294 |
+
fields_with_validators.append(field)
|
| 295 |
+
|
| 296 |
+
required.extend(optional)
|
| 297 |
+
|
| 298 |
+
pre_init = getattr(cls, "__attrs_pre_init__", None)
|
| 299 |
+
post_init = getattr(cls, "__attrs_post_init__", None)
|
| 300 |
+
|
| 301 |
+
if fields_with_validators:
|
| 302 |
+
post_init = _wrap_attrs_validators(fields_with_validators, post_init)
|
| 303 |
+
|
| 304 |
+
return cls, tuple(required), tuple(defaults), pre_init, post_init
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def _wrap_attrs_validators(fields, post_init):
|
| 308 |
+
def inner(obj):
|
| 309 |
+
for field in fields:
|
| 310 |
+
field.validator(obj, field, getattr(obj, field.name))
|
| 311 |
+
if post_init is not None:
|
| 312 |
+
post_init(obj)
|
| 313 |
+
|
| 314 |
+
return inner
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
def rebuild(cls, kwargs):
|
| 318 |
+
"""Used to unpickle Structs with keyword-only fields"""
|
| 319 |
+
return cls(**kwargs)
|
.venv/lib/python3.11/site-packages/msgspec/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# This file was generated by 'versioneer.py' (0.19) from
|
| 3 |
+
# revision-control system data, or from the parent directory name of an
|
| 4 |
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
| 5 |
+
# of this file.
|
| 6 |
+
|
| 7 |
+
import json
|
| 8 |
+
|
| 9 |
+
version_json = '''
|
| 10 |
+
{
|
| 11 |
+
"date": "2024-12-27T11:06:58-0600",
|
| 12 |
+
"dirty": false,
|
| 13 |
+
"error": null,
|
| 14 |
+
"full-revisionid": "dd965dce22e5278d4935bea923441ecde31b5325",
|
| 15 |
+
"version": "0.19.0"
|
| 16 |
+
}
|
| 17 |
+
''' # END VERSION_JSON
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def get_versions():
|
| 21 |
+
return json.loads(version_json)
|
.venv/lib/python3.11/site-packages/msgspec/inspect.py
ADDED
|
@@ -0,0 +1,1005 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import datetime
|
| 4 |
+
import decimal
|
| 5 |
+
import enum
|
| 6 |
+
import uuid
|
| 7 |
+
from collections.abc import Iterable
|
| 8 |
+
from typing import (
|
| 9 |
+
Any,
|
| 10 |
+
Final,
|
| 11 |
+
Literal,
|
| 12 |
+
Tuple,
|
| 13 |
+
Type as typing_Type,
|
| 14 |
+
TypeVar,
|
| 15 |
+
Union,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
from types import UnionType as _types_UnionType # type: ignore
|
| 20 |
+
except Exception:
|
| 21 |
+
_types_UnionType = type("UnionType", (), {}) # type: ignore
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
from typing import TypeAliasType as _TypeAliasType # type: ignore
|
| 25 |
+
except Exception:
|
| 26 |
+
_TypeAliasType = type("TypeAliasType", (), {}) # type: ignore
|
| 27 |
+
|
| 28 |
+
import msgspec
|
| 29 |
+
from msgspec import NODEFAULT, UNSET, UnsetType as _UnsetType
|
| 30 |
+
|
| 31 |
+
from ._core import ( # type: ignore
|
| 32 |
+
Factory as _Factory,
|
| 33 |
+
to_builtins as _to_builtins,
|
| 34 |
+
)
|
| 35 |
+
from ._utils import ( # type: ignore
|
| 36 |
+
_CONCRETE_TYPES,
|
| 37 |
+
_AnnotatedAlias,
|
| 38 |
+
get_class_annotations as _get_class_annotations,
|
| 39 |
+
get_dataclass_info as _get_dataclass_info,
|
| 40 |
+
get_typeddict_info as _get_typeddict_info,
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
__all__ = (
|
| 44 |
+
"type_info",
|
| 45 |
+
"multi_type_info",
|
| 46 |
+
"Type",
|
| 47 |
+
"Metadata",
|
| 48 |
+
"AnyType",
|
| 49 |
+
"NoneType",
|
| 50 |
+
"BoolType",
|
| 51 |
+
"IntType",
|
| 52 |
+
"FloatType",
|
| 53 |
+
"StrType",
|
| 54 |
+
"BytesType",
|
| 55 |
+
"ByteArrayType",
|
| 56 |
+
"MemoryViewType",
|
| 57 |
+
"DateTimeType",
|
| 58 |
+
"TimeType",
|
| 59 |
+
"DateType",
|
| 60 |
+
"TimeDeltaType",
|
| 61 |
+
"UUIDType",
|
| 62 |
+
"DecimalType",
|
| 63 |
+
"ExtType",
|
| 64 |
+
"RawType",
|
| 65 |
+
"EnumType",
|
| 66 |
+
"LiteralType",
|
| 67 |
+
"CustomType",
|
| 68 |
+
"UnionType",
|
| 69 |
+
"CollectionType",
|
| 70 |
+
"ListType",
|
| 71 |
+
"SetType",
|
| 72 |
+
"FrozenSetType",
|
| 73 |
+
"VarTupleType",
|
| 74 |
+
"TupleType",
|
| 75 |
+
"DictType",
|
| 76 |
+
"Field",
|
| 77 |
+
"TypedDictType",
|
| 78 |
+
"NamedTupleType",
|
| 79 |
+
"DataclassType",
|
| 80 |
+
"StructType",
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def __dir__():
|
| 85 |
+
return __all__
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
class Type(msgspec.Struct):
|
| 89 |
+
"""The base Type."""
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
class Metadata(Type):
|
| 93 |
+
"""A type wrapping a subtype with additional metadata.
|
| 94 |
+
|
| 95 |
+
Parameters
|
| 96 |
+
----------
|
| 97 |
+
type: Type
|
| 98 |
+
The subtype.
|
| 99 |
+
extra_json_schema: dict, optional
|
| 100 |
+
A dict of extra fields to set for the subtype when generating a
|
| 101 |
+
json-schema.
|
| 102 |
+
extra: dict, optional
|
| 103 |
+
A dict of extra user-defined metadata attached to the subtype.
|
| 104 |
+
"""
|
| 105 |
+
|
| 106 |
+
type: Type
|
| 107 |
+
extra_json_schema: Union[dict, None] = None
|
| 108 |
+
extra: Union[dict, None] = None
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
class AnyType(Type):
|
| 112 |
+
"""A type corresponding to `typing.Any`."""
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class NoneType(Type):
|
| 116 |
+
"""A type corresponding to `None`."""
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
class BoolType(Type):
|
| 120 |
+
"""A type corresponding to `bool`."""
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class IntType(Type):
|
| 124 |
+
"""A type corresponding to `int`.
|
| 125 |
+
|
| 126 |
+
Parameters
|
| 127 |
+
----------
|
| 128 |
+
gt: int, optional
|
| 129 |
+
If set, an instance of this type must be greater than ``gt``.
|
| 130 |
+
ge: int, optional
|
| 131 |
+
If set, an instance of this type must be greater than or equal to ``ge``.
|
| 132 |
+
lt: int, optional
|
| 133 |
+
If set, an instance of this type must be less than to ``lt``.
|
| 134 |
+
le: int, optional
|
| 135 |
+
If set, an instance of this type must be less than or equal to ``le``.
|
| 136 |
+
multiple_of: int, optional
|
| 137 |
+
If set, an instance of this type must be a multiple of ``multiple_of``.
|
| 138 |
+
"""
|
| 139 |
+
|
| 140 |
+
gt: Union[int, None] = None
|
| 141 |
+
ge: Union[int, None] = None
|
| 142 |
+
lt: Union[int, None] = None
|
| 143 |
+
le: Union[int, None] = None
|
| 144 |
+
multiple_of: Union[int, None] = None
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class FloatType(Type):
|
| 148 |
+
"""A type corresponding to `float`.
|
| 149 |
+
|
| 150 |
+
Parameters
|
| 151 |
+
----------
|
| 152 |
+
gt: float, optional
|
| 153 |
+
If set, an instance of this type must be greater than ``gt``.
|
| 154 |
+
ge: float, optional
|
| 155 |
+
If set, an instance of this type must be greater than or equal to ``ge``.
|
| 156 |
+
lt: float, optional
|
| 157 |
+
If set, an instance of this type must be less than to ``lt``.
|
| 158 |
+
le: float, optional
|
| 159 |
+
If set, an instance of this type must be less than or equal to ``le``.
|
| 160 |
+
multiple_of: float, optional
|
| 161 |
+
If set, an instance of this type must be a multiple of ``multiple_of``.
|
| 162 |
+
"""
|
| 163 |
+
|
| 164 |
+
gt: Union[float, None] = None
|
| 165 |
+
ge: Union[float, None] = None
|
| 166 |
+
lt: Union[float, None] = None
|
| 167 |
+
le: Union[float, None] = None
|
| 168 |
+
multiple_of: Union[float, None] = None
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
class StrType(Type):
|
| 172 |
+
"""A type corresponding to `str`.
|
| 173 |
+
|
| 174 |
+
Parameters
|
| 175 |
+
----------
|
| 176 |
+
min_length: int, optional
|
| 177 |
+
If set, an instance of this type must have length greater than or equal
|
| 178 |
+
to ``min_length``.
|
| 179 |
+
max_length: int, optional
|
| 180 |
+
If set, an instance of this type must have length less than or equal
|
| 181 |
+
to ``max_length``.
|
| 182 |
+
pattern: str, optional
|
| 183 |
+
If set, an instance of this type must match against this regex pattern.
|
| 184 |
+
Note that the pattern is treated as **unanchored**.
|
| 185 |
+
"""
|
| 186 |
+
|
| 187 |
+
min_length: Union[int, None] = None
|
| 188 |
+
max_length: Union[int, None] = None
|
| 189 |
+
pattern: Union[str, None] = None
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
class BytesType(Type):
|
| 193 |
+
"""A type corresponding to `bytes`.
|
| 194 |
+
|
| 195 |
+
Parameters
|
| 196 |
+
----------
|
| 197 |
+
min_length: int, optional
|
| 198 |
+
If set, an instance of this type must have length greater than or equal
|
| 199 |
+
to ``min_length``.
|
| 200 |
+
max_length: int, optional
|
| 201 |
+
If set, an instance of this type must have length less than or equal
|
| 202 |
+
to ``max_length``.
|
| 203 |
+
"""
|
| 204 |
+
|
| 205 |
+
min_length: Union[int, None] = None
|
| 206 |
+
max_length: Union[int, None] = None
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
class ByteArrayType(Type):
|
| 210 |
+
"""A type corresponding to `bytearray`.
|
| 211 |
+
|
| 212 |
+
Parameters
|
| 213 |
+
----------
|
| 214 |
+
min_length: int, optional
|
| 215 |
+
If set, an instance of this type must have length greater than or equal
|
| 216 |
+
to ``min_length``.
|
| 217 |
+
max_length: int, optional
|
| 218 |
+
If set, an instance of this type must have length less than or equal
|
| 219 |
+
to ``max_length``.
|
| 220 |
+
"""
|
| 221 |
+
|
| 222 |
+
min_length: Union[int, None] = None
|
| 223 |
+
max_length: Union[int, None] = None
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
class MemoryViewType(Type):
|
| 227 |
+
"""A type corresponding to `memoryview`.
|
| 228 |
+
|
| 229 |
+
Parameters
|
| 230 |
+
----------
|
| 231 |
+
min_length: int, optional
|
| 232 |
+
If set, an instance of this type must have length greater than or equal
|
| 233 |
+
to ``min_length``.
|
| 234 |
+
max_length: int, optional
|
| 235 |
+
If set, an instance of this type must have length less than or equal
|
| 236 |
+
to ``max_length``.
|
| 237 |
+
"""
|
| 238 |
+
|
| 239 |
+
min_length: Union[int, None] = None
|
| 240 |
+
max_length: Union[int, None] = None
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
class DateTimeType(Type):
|
| 244 |
+
"""A type corresponding to `datetime.datetime`.
|
| 245 |
+
|
| 246 |
+
Parameters
|
| 247 |
+
----------
|
| 248 |
+
tz: bool
|
| 249 |
+
The timezone-requirements for an instance of this type. ``True``
|
| 250 |
+
indicates a timezone-aware value is required, ``False`` indicates a
|
| 251 |
+
timezone-aware value is required. The default is ``None``, which
|
| 252 |
+
accepts either timezone-aware or timezone-naive values.
|
| 253 |
+
"""
|
| 254 |
+
|
| 255 |
+
tz: Union[bool, None] = None
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
class TimeType(Type):
|
| 259 |
+
"""A type corresponding to `datetime.time`.
|
| 260 |
+
|
| 261 |
+
Parameters
|
| 262 |
+
----------
|
| 263 |
+
tz: bool
|
| 264 |
+
The timezone-requirements for an instance of this type. ``True``
|
| 265 |
+
indicates a timezone-aware value is required, ``False`` indicates a
|
| 266 |
+
timezone-aware value is required. The default is ``None``, which
|
| 267 |
+
accepts either timezone-aware or timezone-naive values.
|
| 268 |
+
"""
|
| 269 |
+
|
| 270 |
+
tz: Union[bool, None] = None
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
class DateType(Type):
|
| 274 |
+
"""A type corresponding to `datetime.date`."""
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
class TimeDeltaType(Type):
|
| 278 |
+
"""A type corresponding to `datetime.timedelta`."""
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
class UUIDType(Type):
|
| 282 |
+
"""A type corresponding to `uuid.UUID`."""
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
class DecimalType(Type):
|
| 286 |
+
"""A type corresponding to `decimal.Decimal`."""
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
class ExtType(Type):
|
| 290 |
+
"""A type corresponding to `msgspec.msgpack.Ext`."""
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
class RawType(Type):
|
| 294 |
+
"""A type corresponding to `msgspec.Raw`."""
|
| 295 |
+
|
| 296 |
+
|
| 297 |
+
class EnumType(Type):
|
| 298 |
+
"""A type corresponding to an `enum.Enum` type.
|
| 299 |
+
|
| 300 |
+
Parameters
|
| 301 |
+
----------
|
| 302 |
+
cls: type
|
| 303 |
+
The corresponding `enum.Enum` type.
|
| 304 |
+
"""
|
| 305 |
+
|
| 306 |
+
cls: typing_Type[enum.Enum]
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
class LiteralType(Type):
|
| 310 |
+
"""A type corresponding to a `typing.Literal` type.
|
| 311 |
+
|
| 312 |
+
Parameters
|
| 313 |
+
----------
|
| 314 |
+
values: tuple
|
| 315 |
+
A tuple of possible values for this literal instance. Only `str` or
|
| 316 |
+
`int` literals are supported.
|
| 317 |
+
"""
|
| 318 |
+
|
| 319 |
+
values: Union[Tuple[str, ...], Tuple[int, ...]]
|
| 320 |
+
|
| 321 |
+
|
| 322 |
+
class CustomType(Type):
|
| 323 |
+
"""A custom type.
|
| 324 |
+
|
| 325 |
+
Parameters
|
| 326 |
+
----------
|
| 327 |
+
cls: type
|
| 328 |
+
The corresponding custom type.
|
| 329 |
+
"""
|
| 330 |
+
|
| 331 |
+
cls: type
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
class UnionType(Type):
|
| 335 |
+
"""A union type.
|
| 336 |
+
|
| 337 |
+
Parameters
|
| 338 |
+
----------
|
| 339 |
+
types: Tuple[Type, ...]
|
| 340 |
+
A tuple of possible types for this union.
|
| 341 |
+
"""
|
| 342 |
+
|
| 343 |
+
types: Tuple[Type, ...]
|
| 344 |
+
|
| 345 |
+
@property
|
| 346 |
+
def includes_none(self) -> bool:
|
| 347 |
+
"""A helper for checking whether ``None`` is included in this union."""
|
| 348 |
+
return any(isinstance(t, NoneType) for t in self.types)
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
class CollectionType(Type):
|
| 352 |
+
"""A collection type.
|
| 353 |
+
|
| 354 |
+
This is the base type shared by collection types like `ListType`,
|
| 355 |
+
`SetType`, etc.
|
| 356 |
+
|
| 357 |
+
Parameters
|
| 358 |
+
----------
|
| 359 |
+
item_type: Type
|
| 360 |
+
The item type.
|
| 361 |
+
min_length: int, optional
|
| 362 |
+
If set, an instance of this type must have length greater than or equal
|
| 363 |
+
to ``min_length``.
|
| 364 |
+
max_length: int, optional
|
| 365 |
+
If set, an instance of this type must have length less than or equal
|
| 366 |
+
to ``max_length``.
|
| 367 |
+
"""
|
| 368 |
+
|
| 369 |
+
item_type: Type
|
| 370 |
+
min_length: Union[int, None] = None
|
| 371 |
+
max_length: Union[int, None] = None
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
class ListType(CollectionType):
|
| 375 |
+
"""A type corresponding to a `list`.
|
| 376 |
+
|
| 377 |
+
Parameters
|
| 378 |
+
----------
|
| 379 |
+
item_type: Type
|
| 380 |
+
The item type.
|
| 381 |
+
min_length: int, optional
|
| 382 |
+
If set, an instance of this type must have length greater than or equal
|
| 383 |
+
to ``min_length``.
|
| 384 |
+
max_length: int, optional
|
| 385 |
+
If set, an instance of this type must have length less than or equal
|
| 386 |
+
to ``max_length``.
|
| 387 |
+
"""
|
| 388 |
+
|
| 389 |
+
|
| 390 |
+
class VarTupleType(CollectionType):
|
| 391 |
+
"""A type corresponding to a variadic `tuple`.
|
| 392 |
+
|
| 393 |
+
Parameters
|
| 394 |
+
----------
|
| 395 |
+
item_type: Type
|
| 396 |
+
The item type.
|
| 397 |
+
min_length: int, optional
|
| 398 |
+
If set, an instance of this type must have length greater than or equal
|
| 399 |
+
to ``min_length``.
|
| 400 |
+
max_length: int, optional
|
| 401 |
+
If set, an instance of this type must have length less than or equal
|
| 402 |
+
to ``max_length``.
|
| 403 |
+
"""
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
class SetType(CollectionType):
|
| 407 |
+
"""A type corresponding to a `set`.
|
| 408 |
+
|
| 409 |
+
Parameters
|
| 410 |
+
----------
|
| 411 |
+
item_type: Type
|
| 412 |
+
The item type.
|
| 413 |
+
min_length: int, optional
|
| 414 |
+
If set, an instance of this type must have length greater than or equal
|
| 415 |
+
to ``min_length``.
|
| 416 |
+
max_length: int, optional
|
| 417 |
+
If set, an instance of this type must have length less than or equal
|
| 418 |
+
to ``max_length``.
|
| 419 |
+
"""
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
class FrozenSetType(CollectionType):
|
| 423 |
+
"""A type corresponding to a `frozenset`.
|
| 424 |
+
|
| 425 |
+
Parameters
|
| 426 |
+
----------
|
| 427 |
+
item_type: Type
|
| 428 |
+
The item type.
|
| 429 |
+
min_length: int, optional
|
| 430 |
+
If set, an instance of this type must have length greater than or equal
|
| 431 |
+
to ``min_length``.
|
| 432 |
+
max_length: int, optional
|
| 433 |
+
If set, an instance of this type must have length less than or equal
|
| 434 |
+
to ``max_length``.
|
| 435 |
+
"""
|
| 436 |
+
|
| 437 |
+
|
| 438 |
+
class TupleType(Type):
|
| 439 |
+
"""A type corresponding to `tuple`.
|
| 440 |
+
|
| 441 |
+
Parameters
|
| 442 |
+
----------
|
| 443 |
+
item_types: Tuple[Type, ...]
|
| 444 |
+
A tuple of types for each element in the tuple.
|
| 445 |
+
"""
|
| 446 |
+
|
| 447 |
+
item_types: Tuple[Type, ...]
|
| 448 |
+
|
| 449 |
+
|
| 450 |
+
class DictType(Type):
|
| 451 |
+
"""A type corresponding to `dict`.
|
| 452 |
+
|
| 453 |
+
Parameters
|
| 454 |
+
----------
|
| 455 |
+
key_type: Type
|
| 456 |
+
The key type.
|
| 457 |
+
value_type: Type
|
| 458 |
+
The value type.
|
| 459 |
+
min_length: int, optional
|
| 460 |
+
If set, an instance of this type must have length greater than or equal
|
| 461 |
+
to ``min_length``.
|
| 462 |
+
max_length: int, optional
|
| 463 |
+
If set, an instance of this type must have length less than or equal
|
| 464 |
+
to ``max_length``.
|
| 465 |
+
"""
|
| 466 |
+
|
| 467 |
+
key_type: Type
|
| 468 |
+
value_type: Type
|
| 469 |
+
min_length: Union[int, None] = None
|
| 470 |
+
max_length: Union[int, None] = None
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
class Field(msgspec.Struct):
|
| 474 |
+
"""A record describing a field in an object-like type.
|
| 475 |
+
|
| 476 |
+
Parameters
|
| 477 |
+
----------
|
| 478 |
+
name: str
|
| 479 |
+
The field name as seen by Python code (e.g. ``field_one``).
|
| 480 |
+
encode_name: str
|
| 481 |
+
The name used when encoding/decoding the field. This may differ if
|
| 482 |
+
the field is renamed (e.g. ``fieldOne``).
|
| 483 |
+
type: Type
|
| 484 |
+
The field type.
|
| 485 |
+
required: bool, optional
|
| 486 |
+
Whether the field is required. Note that if `required` is False doesn't
|
| 487 |
+
necessarily mean that `default` or `default_factory` will be set -
|
| 488 |
+
optional fields may exist with no default value.
|
| 489 |
+
default: Any, optional
|
| 490 |
+
A default value for the field. Will be `NODEFAULT` if no default value
|
| 491 |
+
is set.
|
| 492 |
+
default_factory: Any, optional
|
| 493 |
+
A callable that creates a default value for the field. Will be
|
| 494 |
+
`NODEFAULT` if no ``default_factory`` is set.
|
| 495 |
+
"""
|
| 496 |
+
|
| 497 |
+
name: str
|
| 498 |
+
encode_name: str
|
| 499 |
+
type: Type
|
| 500 |
+
required: bool = True
|
| 501 |
+
default: Any = msgspec.field(default_factory=lambda: NODEFAULT)
|
| 502 |
+
default_factory: Any = msgspec.field(default_factory=lambda: NODEFAULT)
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
class TypedDictType(Type):
|
| 506 |
+
"""A type corresponding to a `typing.TypedDict` type.
|
| 507 |
+
|
| 508 |
+
Parameters
|
| 509 |
+
----------
|
| 510 |
+
cls: type
|
| 511 |
+
The corresponding TypedDict type.
|
| 512 |
+
fields: Tuple[Field, ...]
|
| 513 |
+
A tuple of fields in the TypedDict.
|
| 514 |
+
"""
|
| 515 |
+
|
| 516 |
+
cls: type
|
| 517 |
+
fields: Tuple[Field, ...]
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
class NamedTupleType(Type):
|
| 521 |
+
"""A type corresponding to a `typing.NamedTuple` type.
|
| 522 |
+
|
| 523 |
+
Parameters
|
| 524 |
+
----------
|
| 525 |
+
cls: type
|
| 526 |
+
The corresponding NamedTuple type.
|
| 527 |
+
fields: Tuple[Field, ...]
|
| 528 |
+
A tuple of fields in the NamedTuple.
|
| 529 |
+
"""
|
| 530 |
+
|
| 531 |
+
cls: type
|
| 532 |
+
fields: Tuple[Field, ...]
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
class DataclassType(Type):
|
| 536 |
+
"""A type corresponding to a `dataclasses` or `attrs` type.
|
| 537 |
+
|
| 538 |
+
Parameters
|
| 539 |
+
----------
|
| 540 |
+
cls: type
|
| 541 |
+
The corresponding dataclass type.
|
| 542 |
+
fields: Tuple[Field, ...]
|
| 543 |
+
A tuple of fields in the dataclass.
|
| 544 |
+
"""
|
| 545 |
+
|
| 546 |
+
cls: type
|
| 547 |
+
fields: Tuple[Field, ...]
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
class StructType(Type):
|
| 551 |
+
"""A type corresponding to a `msgspec.Struct` type.
|
| 552 |
+
|
| 553 |
+
Parameters
|
| 554 |
+
----------
|
| 555 |
+
cls: type
|
| 556 |
+
The corresponding Struct type.
|
| 557 |
+
fields: Tuple[Field, ...]
|
| 558 |
+
A tuple of fields in the Struct.
|
| 559 |
+
tag_field: str or None, optional
|
| 560 |
+
If set, the field name used for the tag in a tagged union.
|
| 561 |
+
tag: str, int, or None, optional
|
| 562 |
+
If set, the value used for the tag in a tagged union.
|
| 563 |
+
array_like: bool, optional
|
| 564 |
+
Whether the struct is encoded as an array rather than an object.
|
| 565 |
+
forbid_unknown_fields: bool, optional
|
| 566 |
+
If ``False`` (the default) unknown fields are ignored when decoding. If
|
| 567 |
+
``True`` any unknown fields will result in an error.
|
| 568 |
+
"""
|
| 569 |
+
|
| 570 |
+
cls: typing_Type[msgspec.Struct]
|
| 571 |
+
fields: Tuple[Field, ...]
|
| 572 |
+
tag_field: Union[str, None] = None
|
| 573 |
+
tag: Union[str, int, None] = None
|
| 574 |
+
array_like: bool = False
|
| 575 |
+
forbid_unknown_fields: bool = False
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
def multi_type_info(types: Iterable[Any]) -> tuple[Type, ...]:
|
| 579 |
+
"""Get information about multiple msgspec-compatible types.
|
| 580 |
+
|
| 581 |
+
Parameters
|
| 582 |
+
----------
|
| 583 |
+
types: an iterable of types
|
| 584 |
+
The types to get info about.
|
| 585 |
+
|
| 586 |
+
Returns
|
| 587 |
+
-------
|
| 588 |
+
tuple[Type, ...]
|
| 589 |
+
|
| 590 |
+
Examples
|
| 591 |
+
--------
|
| 592 |
+
>>> msgspec.inspect.multi_type_info([int, float, list[str]]) # doctest: +NORMALIZE_WHITESPACE
|
| 593 |
+
(IntType(gt=None, ge=None, lt=None, le=None, multiple_of=None),
|
| 594 |
+
FloatType(gt=None, ge=None, lt=None, le=None, multiple_of=None),
|
| 595 |
+
ListType(item_type=StrType(min_length=None, max_length=None, pattern=None),
|
| 596 |
+
min_length=None, max_length=None))
|
| 597 |
+
"""
|
| 598 |
+
return _Translator(types).run()
|
| 599 |
+
|
| 600 |
+
|
| 601 |
+
def type_info(type: Any) -> Type:
|
| 602 |
+
"""Get information about a msgspec-compatible type.
|
| 603 |
+
|
| 604 |
+
Note that if you need to inspect multiple types it's more efficient to call
|
| 605 |
+
`multi_type_info` once with a sequence of types than calling `type_info`
|
| 606 |
+
multiple times.
|
| 607 |
+
|
| 608 |
+
Parameters
|
| 609 |
+
----------
|
| 610 |
+
type: type
|
| 611 |
+
The type to get info about.
|
| 612 |
+
|
| 613 |
+
Returns
|
| 614 |
+
-------
|
| 615 |
+
Type
|
| 616 |
+
|
| 617 |
+
Examples
|
| 618 |
+
--------
|
| 619 |
+
>>> msgspec.inspect.type_info(bool)
|
| 620 |
+
BoolType()
|
| 621 |
+
|
| 622 |
+
>>> msgspec.inspect.type_info(int)
|
| 623 |
+
IntType(gt=None, ge=None, lt=None, le=None, multiple_of=None)
|
| 624 |
+
|
| 625 |
+
>>> msgspec.inspect.type_info(list[int]) # doctest: +NORMALIZE_WHITESPACE
|
| 626 |
+
ListType(item_type=IntType(gt=None, ge=None, lt=None, le=None, multiple_of=None),
|
| 627 |
+
min_length=None, max_length=None)
|
| 628 |
+
"""
|
| 629 |
+
return multi_type_info([type])[0]
|
| 630 |
+
|
| 631 |
+
|
| 632 |
+
# Implementation details
|
| 633 |
+
def _origin_args_metadata(t):
|
| 634 |
+
# Strip wrappers (Annotated, NewType, Final) until we hit a concrete type
|
| 635 |
+
metadata = []
|
| 636 |
+
while True:
|
| 637 |
+
try:
|
| 638 |
+
origin = _CONCRETE_TYPES.get(t)
|
| 639 |
+
except TypeError:
|
| 640 |
+
# t is not hashable
|
| 641 |
+
origin = None
|
| 642 |
+
|
| 643 |
+
if origin is not None:
|
| 644 |
+
args = None
|
| 645 |
+
break
|
| 646 |
+
|
| 647 |
+
origin = getattr(t, "__origin__", None)
|
| 648 |
+
if origin is not None:
|
| 649 |
+
if type(t) is _AnnotatedAlias:
|
| 650 |
+
metadata.extend(m for m in t.__metadata__ if type(m) is msgspec.Meta)
|
| 651 |
+
t = origin
|
| 652 |
+
elif origin == Final:
|
| 653 |
+
t = t.__args__[0]
|
| 654 |
+
elif type(origin) is _TypeAliasType:
|
| 655 |
+
t = origin.__value__[t.__args__]
|
| 656 |
+
else:
|
| 657 |
+
args = getattr(t, "__args__", None)
|
| 658 |
+
origin = _CONCRETE_TYPES.get(origin, origin)
|
| 659 |
+
break
|
| 660 |
+
else:
|
| 661 |
+
supertype = getattr(t, "__supertype__", None)
|
| 662 |
+
if supertype is not None:
|
| 663 |
+
t = supertype
|
| 664 |
+
elif type(t) is _TypeAliasType:
|
| 665 |
+
t = t.__value__
|
| 666 |
+
else:
|
| 667 |
+
origin = t
|
| 668 |
+
args = None
|
| 669 |
+
break
|
| 670 |
+
|
| 671 |
+
if type(origin) is _types_UnionType:
|
| 672 |
+
args = origin.__args__
|
| 673 |
+
origin = Union
|
| 674 |
+
return origin, args, tuple(metadata)
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
def _is_struct(t):
|
| 678 |
+
return type(t) is type(msgspec.Struct)
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
def _is_enum(t):
|
| 682 |
+
return type(t) is enum.EnumMeta
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
def _is_dataclass(t):
|
| 686 |
+
return hasattr(t, "__dataclass_fields__")
|
| 687 |
+
|
| 688 |
+
|
| 689 |
+
def _is_attrs(t):
|
| 690 |
+
return hasattr(t, "__attrs_attrs__")
|
| 691 |
+
|
| 692 |
+
|
| 693 |
+
def _is_typeddict(t):
|
| 694 |
+
try:
|
| 695 |
+
return issubclass(t, dict) and hasattr(t, "__total__")
|
| 696 |
+
except TypeError:
|
| 697 |
+
return False
|
| 698 |
+
|
| 699 |
+
|
| 700 |
+
def _is_namedtuple(t):
|
| 701 |
+
try:
|
| 702 |
+
return issubclass(t, tuple) and hasattr(t, "_fields")
|
| 703 |
+
except TypeError:
|
| 704 |
+
return False
|
| 705 |
+
|
| 706 |
+
|
| 707 |
+
def _merge_json(a, b):
|
| 708 |
+
if b:
|
| 709 |
+
a = a.copy()
|
| 710 |
+
for key, b_val in b.items():
|
| 711 |
+
if key in a:
|
| 712 |
+
a_val = a[key]
|
| 713 |
+
if isinstance(a_val, dict) and isinstance(b_val, dict):
|
| 714 |
+
a[key] = _merge_json(a_val, b_val)
|
| 715 |
+
elif isinstance(a_val, (list, tuple)) and isinstance(
|
| 716 |
+
b_val, (list, tuple)
|
| 717 |
+
):
|
| 718 |
+
a[key] = list(a_val) + list(b_val)
|
| 719 |
+
else:
|
| 720 |
+
a[key] = b_val
|
| 721 |
+
else:
|
| 722 |
+
a[key] = b_val
|
| 723 |
+
return a
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
class _Translator:
|
| 727 |
+
def __init__(self, types):
|
| 728 |
+
self.types = tuple(types)
|
| 729 |
+
self.type_hints = {}
|
| 730 |
+
self.cache = {}
|
| 731 |
+
|
| 732 |
+
def _get_class_annotations(self, t):
|
| 733 |
+
"""A cached version of `get_class_annotations`"""
|
| 734 |
+
try:
|
| 735 |
+
return self.type_hints[t]
|
| 736 |
+
except KeyError:
|
| 737 |
+
out = self.type_hints[t] = _get_class_annotations(t)
|
| 738 |
+
return out
|
| 739 |
+
|
| 740 |
+
def run(self):
|
| 741 |
+
# First construct a decoder to validate the types are valid
|
| 742 |
+
from ._core import MsgpackDecoder
|
| 743 |
+
|
| 744 |
+
MsgpackDecoder(Tuple[self.types])
|
| 745 |
+
return tuple(self.translate(t) for t in self.types)
|
| 746 |
+
|
| 747 |
+
def translate(self, typ):
|
| 748 |
+
t, args, metadata = _origin_args_metadata(typ)
|
| 749 |
+
|
| 750 |
+
# Extract and merge components of any `Meta` annotations
|
| 751 |
+
constrs = {}
|
| 752 |
+
extra_json_schema = {}
|
| 753 |
+
extra = {}
|
| 754 |
+
for meta in metadata:
|
| 755 |
+
for attr in (
|
| 756 |
+
"ge",
|
| 757 |
+
"gt",
|
| 758 |
+
"le",
|
| 759 |
+
"lt",
|
| 760 |
+
"multiple_of",
|
| 761 |
+
"pattern",
|
| 762 |
+
"min_length",
|
| 763 |
+
"max_length",
|
| 764 |
+
"tz",
|
| 765 |
+
):
|
| 766 |
+
if (val := getattr(meta, attr)) is not None:
|
| 767 |
+
constrs[attr] = val
|
| 768 |
+
for attr in ("title", "description", "examples"):
|
| 769 |
+
if (val := getattr(meta, attr)) is not None:
|
| 770 |
+
extra_json_schema[attr] = val
|
| 771 |
+
if meta.extra_json_schema is not None:
|
| 772 |
+
extra_json_schema = _merge_json(
|
| 773 |
+
extra_json_schema,
|
| 774 |
+
_to_builtins(meta.extra_json_schema, str_keys=True),
|
| 775 |
+
)
|
| 776 |
+
if meta.extra is not None:
|
| 777 |
+
extra.update(meta.extra)
|
| 778 |
+
|
| 779 |
+
out = self._translate_inner(t, args, **constrs)
|
| 780 |
+
if extra_json_schema or extra:
|
| 781 |
+
# If extra metadata is present, wrap the output type in a Metadata
|
| 782 |
+
# wrapper object
|
| 783 |
+
return Metadata(
|
| 784 |
+
out, extra_json_schema=extra_json_schema or None, extra=extra or None
|
| 785 |
+
)
|
| 786 |
+
return out
|
| 787 |
+
|
| 788 |
+
def _translate_inner(
|
| 789 |
+
self,
|
| 790 |
+
t,
|
| 791 |
+
args,
|
| 792 |
+
ge=None,
|
| 793 |
+
gt=None,
|
| 794 |
+
le=None,
|
| 795 |
+
lt=None,
|
| 796 |
+
multiple_of=None,
|
| 797 |
+
pattern=None,
|
| 798 |
+
min_length=None,
|
| 799 |
+
max_length=None,
|
| 800 |
+
tz=None,
|
| 801 |
+
):
|
| 802 |
+
if t is Any:
|
| 803 |
+
return AnyType()
|
| 804 |
+
elif isinstance(t, TypeVar):
|
| 805 |
+
if t.__bound__ is not None:
|
| 806 |
+
return self.translate(t.__bound__)
|
| 807 |
+
return AnyType()
|
| 808 |
+
elif t is None or t is type(None):
|
| 809 |
+
return NoneType()
|
| 810 |
+
elif t is bool:
|
| 811 |
+
return BoolType()
|
| 812 |
+
elif t is int:
|
| 813 |
+
return IntType(ge=ge, gt=gt, le=le, lt=lt, multiple_of=multiple_of)
|
| 814 |
+
elif t is float:
|
| 815 |
+
return FloatType(ge=ge, gt=gt, le=le, lt=lt, multiple_of=multiple_of)
|
| 816 |
+
elif t is str:
|
| 817 |
+
return StrType(
|
| 818 |
+
min_length=min_length, max_length=max_length, pattern=pattern
|
| 819 |
+
)
|
| 820 |
+
elif t is bytes:
|
| 821 |
+
return BytesType(min_length=min_length, max_length=max_length)
|
| 822 |
+
elif t is bytearray:
|
| 823 |
+
return ByteArrayType(min_length=min_length, max_length=max_length)
|
| 824 |
+
elif t is memoryview:
|
| 825 |
+
return MemoryViewType(min_length=min_length, max_length=max_length)
|
| 826 |
+
elif t is datetime.datetime:
|
| 827 |
+
return DateTimeType(tz=tz)
|
| 828 |
+
elif t is datetime.time:
|
| 829 |
+
return TimeType(tz=tz)
|
| 830 |
+
elif t is datetime.date:
|
| 831 |
+
return DateType()
|
| 832 |
+
elif t is datetime.timedelta:
|
| 833 |
+
return TimeDeltaType()
|
| 834 |
+
elif t is uuid.UUID:
|
| 835 |
+
return UUIDType()
|
| 836 |
+
elif t is decimal.Decimal:
|
| 837 |
+
return DecimalType()
|
| 838 |
+
elif t is msgspec.Raw:
|
| 839 |
+
return RawType()
|
| 840 |
+
elif t is msgspec.msgpack.Ext:
|
| 841 |
+
return ExtType()
|
| 842 |
+
elif t is list:
|
| 843 |
+
return ListType(
|
| 844 |
+
self.translate(args[0]) if args else AnyType(),
|
| 845 |
+
min_length=min_length,
|
| 846 |
+
max_length=max_length,
|
| 847 |
+
)
|
| 848 |
+
elif t is set:
|
| 849 |
+
return SetType(
|
| 850 |
+
self.translate(args[0]) if args else AnyType(),
|
| 851 |
+
min_length=min_length,
|
| 852 |
+
max_length=max_length,
|
| 853 |
+
)
|
| 854 |
+
elif t is frozenset:
|
| 855 |
+
return FrozenSetType(
|
| 856 |
+
self.translate(args[0]) if args else AnyType(),
|
| 857 |
+
min_length=min_length,
|
| 858 |
+
max_length=max_length,
|
| 859 |
+
)
|
| 860 |
+
elif t is tuple:
|
| 861 |
+
# Handle an annoying compatibility issue:
|
| 862 |
+
# - Tuple[()] has args == ((),)
|
| 863 |
+
# - tuple[()] has args == ()
|
| 864 |
+
if args == ((),):
|
| 865 |
+
args = ()
|
| 866 |
+
if args is None:
|
| 867 |
+
return VarTupleType(
|
| 868 |
+
AnyType(), min_length=min_length, max_length=max_length
|
| 869 |
+
)
|
| 870 |
+
elif len(args) == 2 and args[-1] is ...:
|
| 871 |
+
return VarTupleType(
|
| 872 |
+
self.translate(args[0]),
|
| 873 |
+
min_length=min_length,
|
| 874 |
+
max_length=max_length,
|
| 875 |
+
)
|
| 876 |
+
else:
|
| 877 |
+
return TupleType(tuple(self.translate(a) for a in args))
|
| 878 |
+
elif t is dict:
|
| 879 |
+
return DictType(
|
| 880 |
+
self.translate(args[0]) if args else AnyType(),
|
| 881 |
+
self.translate(args[1]) if args else AnyType(),
|
| 882 |
+
min_length=min_length,
|
| 883 |
+
max_length=max_length,
|
| 884 |
+
)
|
| 885 |
+
elif t is Union:
|
| 886 |
+
args = tuple(self.translate(a) for a in args if a is not _UnsetType)
|
| 887 |
+
return args[0] if len(args) == 1 else UnionType(args)
|
| 888 |
+
elif t is Literal:
|
| 889 |
+
return LiteralType(tuple(sorted(args)))
|
| 890 |
+
elif _is_enum(t):
|
| 891 |
+
return EnumType(t)
|
| 892 |
+
elif _is_struct(t):
|
| 893 |
+
cls = t[args] if args else t
|
| 894 |
+
if cls in self.cache:
|
| 895 |
+
return self.cache[cls]
|
| 896 |
+
config = t.__struct_config__
|
| 897 |
+
self.cache[cls] = out = StructType(
|
| 898 |
+
cls,
|
| 899 |
+
(),
|
| 900 |
+
tag_field=config.tag_field,
|
| 901 |
+
tag=config.tag,
|
| 902 |
+
array_like=config.array_like,
|
| 903 |
+
forbid_unknown_fields=config.forbid_unknown_fields,
|
| 904 |
+
)
|
| 905 |
+
|
| 906 |
+
hints = self._get_class_annotations(cls)
|
| 907 |
+
npos = len(t.__struct_fields__) - len(t.__struct_defaults__)
|
| 908 |
+
fields = []
|
| 909 |
+
for name, encode_name, default_obj in zip(
|
| 910 |
+
t.__struct_fields__,
|
| 911 |
+
t.__struct_encode_fields__,
|
| 912 |
+
(NODEFAULT,) * npos + t.__struct_defaults__,
|
| 913 |
+
):
|
| 914 |
+
if default_obj is NODEFAULT:
|
| 915 |
+
required = True
|
| 916 |
+
default = default_factory = NODEFAULT
|
| 917 |
+
elif isinstance(default_obj, _Factory):
|
| 918 |
+
required = False
|
| 919 |
+
default = NODEFAULT
|
| 920 |
+
default_factory = default_obj.factory
|
| 921 |
+
else:
|
| 922 |
+
required = False
|
| 923 |
+
default = NODEFAULT if default_obj is UNSET else default_obj
|
| 924 |
+
default_factory = NODEFAULT
|
| 925 |
+
|
| 926 |
+
field = Field(
|
| 927 |
+
name=name,
|
| 928 |
+
encode_name=encode_name,
|
| 929 |
+
type=self.translate(hints[name]),
|
| 930 |
+
required=required,
|
| 931 |
+
default=default,
|
| 932 |
+
default_factory=default_factory,
|
| 933 |
+
)
|
| 934 |
+
fields.append(field)
|
| 935 |
+
|
| 936 |
+
out.fields = tuple(fields)
|
| 937 |
+
return out
|
| 938 |
+
elif _is_typeddict(t):
|
| 939 |
+
cls = t[args] if args else t
|
| 940 |
+
if cls in self.cache:
|
| 941 |
+
return self.cache[cls]
|
| 942 |
+
self.cache[cls] = out = TypedDictType(cls, ())
|
| 943 |
+
hints, required = _get_typeddict_info(cls)
|
| 944 |
+
out.fields = tuple(
|
| 945 |
+
Field(
|
| 946 |
+
name=name,
|
| 947 |
+
encode_name=name,
|
| 948 |
+
type=self.translate(field_type),
|
| 949 |
+
required=name in required,
|
| 950 |
+
)
|
| 951 |
+
for name, field_type in sorted(hints.items())
|
| 952 |
+
)
|
| 953 |
+
return out
|
| 954 |
+
elif _is_dataclass(t) or _is_attrs(t):
|
| 955 |
+
cls = t[args] if args else t
|
| 956 |
+
if cls in self.cache:
|
| 957 |
+
return self.cache[cls]
|
| 958 |
+
self.cache[cls] = out = DataclassType(cls, ())
|
| 959 |
+
_, info, defaults, _, _ = _get_dataclass_info(cls)
|
| 960 |
+
defaults = ((NODEFAULT,) * (len(info) - len(defaults))) + defaults
|
| 961 |
+
fields = []
|
| 962 |
+
for (name, typ, is_factory), default_obj in zip(info, defaults):
|
| 963 |
+
if default_obj is NODEFAULT:
|
| 964 |
+
required = True
|
| 965 |
+
default = default_factory = NODEFAULT
|
| 966 |
+
elif is_factory:
|
| 967 |
+
required = False
|
| 968 |
+
default = NODEFAULT
|
| 969 |
+
default_factory = default_obj
|
| 970 |
+
else:
|
| 971 |
+
required = False
|
| 972 |
+
default = NODEFAULT if default_obj is UNSET else default_obj
|
| 973 |
+
default_factory = NODEFAULT
|
| 974 |
+
|
| 975 |
+
fields.append(
|
| 976 |
+
Field(
|
| 977 |
+
name=name,
|
| 978 |
+
encode_name=name,
|
| 979 |
+
type=self.translate(typ),
|
| 980 |
+
required=required,
|
| 981 |
+
default=default,
|
| 982 |
+
default_factory=default_factory,
|
| 983 |
+
)
|
| 984 |
+
)
|
| 985 |
+
out.fields = tuple(fields)
|
| 986 |
+
return out
|
| 987 |
+
elif _is_namedtuple(t):
|
| 988 |
+
cls = t[args] if args else t
|
| 989 |
+
if cls in self.cache:
|
| 990 |
+
return self.cache[cls]
|
| 991 |
+
self.cache[cls] = out = NamedTupleType(cls, ())
|
| 992 |
+
hints = self._get_class_annotations(cls)
|
| 993 |
+
out.fields = tuple(
|
| 994 |
+
Field(
|
| 995 |
+
name=name,
|
| 996 |
+
encode_name=name,
|
| 997 |
+
type=self.translate(hints.get(name, Any)),
|
| 998 |
+
required=name not in t._field_defaults,
|
| 999 |
+
default=t._field_defaults.get(name, NODEFAULT),
|
| 1000 |
+
)
|
| 1001 |
+
for name in t._fields
|
| 1002 |
+
)
|
| 1003 |
+
return out
|
| 1004 |
+
else:
|
| 1005 |
+
return CustomType(t)
|
.venv/lib/python3.11/site-packages/msgspec/json.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._core import (
|
| 2 |
+
JSONDecoder as Decoder,
|
| 3 |
+
JSONEncoder as Encoder,
|
| 4 |
+
json_decode as decode,
|
| 5 |
+
json_encode as encode,
|
| 6 |
+
json_format as format,
|
| 7 |
+
)
|
| 8 |
+
from ._json_schema import schema, schema_components
|
.venv/lib/python3.11/site-packages/msgspec/json.pyi
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterable
|
| 2 |
+
from typing import (
|
| 3 |
+
Any,
|
| 4 |
+
Callable,
|
| 5 |
+
Dict,
|
| 6 |
+
Generic,
|
| 7 |
+
Iterable,
|
| 8 |
+
Literal,
|
| 9 |
+
Optional,
|
| 10 |
+
Tuple,
|
| 11 |
+
Type,
|
| 12 |
+
TypeVar,
|
| 13 |
+
Union,
|
| 14 |
+
overload,
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
from typing_extensions import Buffer
|
| 18 |
+
|
| 19 |
+
T = TypeVar("T")
|
| 20 |
+
|
| 21 |
+
enc_hook_sig = Optional[Callable[[Any], Any]]
|
| 22 |
+
dec_hook_sig = Optional[Callable[[type, Any], Any]]
|
| 23 |
+
float_hook_sig = Optional[Callable[[str], Any]]
|
| 24 |
+
schema_hook_sig = Optional[Callable[[type], dict[str, Any]]]
|
| 25 |
+
|
| 26 |
+
class Encoder:
|
| 27 |
+
enc_hook: enc_hook_sig
|
| 28 |
+
decimal_format: Literal["string", "number"]
|
| 29 |
+
uuid_format: Literal["canonical", "hex"]
|
| 30 |
+
order: Literal[None, "deterministic", "sorted"]
|
| 31 |
+
|
| 32 |
+
def __init__(
|
| 33 |
+
self,
|
| 34 |
+
*,
|
| 35 |
+
enc_hook: enc_hook_sig = None,
|
| 36 |
+
decimal_format: Literal["string", "number"] = "string",
|
| 37 |
+
uuid_format: Literal["canonical", "hex"] = "canonical",
|
| 38 |
+
order: Literal[None, "deterministic", "sorted"] = None,
|
| 39 |
+
): ...
|
| 40 |
+
def encode(self, obj: Any, /) -> bytes: ...
|
| 41 |
+
def encode_lines(self, items: Iterable, /) -> bytes: ...
|
| 42 |
+
def encode_into(
|
| 43 |
+
self, obj: Any, buffer: bytearray, offset: Optional[int] = 0, /
|
| 44 |
+
) -> None: ...
|
| 45 |
+
|
| 46 |
+
class Decoder(Generic[T]):
|
| 47 |
+
type: Type[T]
|
| 48 |
+
strict: bool
|
| 49 |
+
dec_hook: dec_hook_sig
|
| 50 |
+
float_hook: float_hook_sig
|
| 51 |
+
|
| 52 |
+
@overload
|
| 53 |
+
def __init__(
|
| 54 |
+
self: Decoder[Any],
|
| 55 |
+
*,
|
| 56 |
+
strict: bool = True,
|
| 57 |
+
dec_hook: dec_hook_sig = None,
|
| 58 |
+
float_hook: float_hook_sig = None,
|
| 59 |
+
) -> None: ...
|
| 60 |
+
@overload
|
| 61 |
+
def __init__(
|
| 62 |
+
self: Decoder[T],
|
| 63 |
+
type: Type[T] = ...,
|
| 64 |
+
*,
|
| 65 |
+
strict: bool = True,
|
| 66 |
+
dec_hook: dec_hook_sig = None,
|
| 67 |
+
float_hook: float_hook_sig = None,
|
| 68 |
+
) -> None: ...
|
| 69 |
+
@overload
|
| 70 |
+
def __init__(
|
| 71 |
+
self: Decoder[Any],
|
| 72 |
+
type: Any = ...,
|
| 73 |
+
*,
|
| 74 |
+
strict: bool = True,
|
| 75 |
+
dec_hook: dec_hook_sig = None,
|
| 76 |
+
float_hook: float_hook_sig = None,
|
| 77 |
+
) -> None: ...
|
| 78 |
+
def decode(self, buf: Union[Buffer, str], /) -> T: ...
|
| 79 |
+
def decode_lines(self, buf: Union[Buffer, str], /) -> list[T]: ...
|
| 80 |
+
|
| 81 |
+
@overload
|
| 82 |
+
def decode(
|
| 83 |
+
buf: Union[Buffer, str],
|
| 84 |
+
/,
|
| 85 |
+
*,
|
| 86 |
+
strict: bool = True,
|
| 87 |
+
dec_hook: dec_hook_sig = None,
|
| 88 |
+
) -> Any: ...
|
| 89 |
+
@overload
|
| 90 |
+
def decode(
|
| 91 |
+
buf: Union[Buffer, str],
|
| 92 |
+
/,
|
| 93 |
+
*,
|
| 94 |
+
type: Type[T] = ...,
|
| 95 |
+
strict: bool = True,
|
| 96 |
+
dec_hook: dec_hook_sig = None,
|
| 97 |
+
) -> T: ...
|
| 98 |
+
@overload
|
| 99 |
+
def decode(
|
| 100 |
+
buf: Union[Buffer, str],
|
| 101 |
+
/,
|
| 102 |
+
*,
|
| 103 |
+
type: Any = ...,
|
| 104 |
+
strict: bool = True,
|
| 105 |
+
dec_hook: dec_hook_sig = None,
|
| 106 |
+
) -> Any: ...
|
| 107 |
+
def encode(obj: Any, /, *, enc_hook: enc_hook_sig = None, order: Literal[None, "deterministic", "sorted"] = None) -> bytes: ...
|
| 108 |
+
def schema(type: Any, *, schema_hook: schema_hook_sig = None) -> Dict[str, Any]: ...
|
| 109 |
+
def schema_components(
|
| 110 |
+
types: Iterable[Any],
|
| 111 |
+
*,
|
| 112 |
+
schema_hook: schema_hook_sig = None,
|
| 113 |
+
ref_template: str = "#/$defs/{name}"
|
| 114 |
+
) -> Tuple[Tuple[Dict[str, Any], ...], Dict[str, Any]]: ...
|
| 115 |
+
@overload
|
| 116 |
+
def format(buf: str, /, *, indent: int = 2) -> str: ...
|
| 117 |
+
@overload
|
| 118 |
+
def format(buf: Buffer, /, *, indent: int = 2) -> bytes: ...
|
.venv/lib/python3.11/site-packages/msgspec/msgpack.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._core import (
|
| 2 |
+
Ext,
|
| 3 |
+
MsgpackDecoder as Decoder,
|
| 4 |
+
MsgpackEncoder as Encoder,
|
| 5 |
+
msgpack_decode as decode,
|
| 6 |
+
msgpack_encode as encode,
|
| 7 |
+
)
|
.venv/lib/python3.11/site-packages/msgspec/msgpack.pyi
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import (
|
| 2 |
+
Any,
|
| 3 |
+
Callable,
|
| 4 |
+
Generic,
|
| 5 |
+
Literal,
|
| 6 |
+
Optional,
|
| 7 |
+
Type,
|
| 8 |
+
TypeVar,
|
| 9 |
+
Union,
|
| 10 |
+
overload,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
from typing_extensions import Buffer
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
T = TypeVar("T")
|
| 17 |
+
|
| 18 |
+
enc_hook_sig = Optional[Callable[[Any], Any]]
|
| 19 |
+
ext_hook_sig = Optional[Callable[[int, memoryview], Any]]
|
| 20 |
+
dec_hook_sig = Optional[Callable[[type, Any], Any]]
|
| 21 |
+
|
| 22 |
+
class Ext:
|
| 23 |
+
code: int
|
| 24 |
+
data: Union[bytes, bytearray, memoryview]
|
| 25 |
+
def __init__(
|
| 26 |
+
self, code: int, data: Union[bytes, bytearray, memoryview]
|
| 27 |
+
) -> None: ...
|
| 28 |
+
|
| 29 |
+
class Decoder(Generic[T]):
|
| 30 |
+
type: Type[T]
|
| 31 |
+
strict: bool
|
| 32 |
+
dec_hook: dec_hook_sig
|
| 33 |
+
ext_hook: ext_hook_sig
|
| 34 |
+
@overload
|
| 35 |
+
def __init__(
|
| 36 |
+
self: Decoder[Any],
|
| 37 |
+
*,
|
| 38 |
+
strict: bool = True,
|
| 39 |
+
dec_hook: dec_hook_sig = None,
|
| 40 |
+
ext_hook: ext_hook_sig = None,
|
| 41 |
+
) -> None: ...
|
| 42 |
+
@overload
|
| 43 |
+
def __init__(
|
| 44 |
+
self: Decoder[T],
|
| 45 |
+
type: Type[T] = ...,
|
| 46 |
+
*,
|
| 47 |
+
strict: bool = True,
|
| 48 |
+
dec_hook: dec_hook_sig = None,
|
| 49 |
+
ext_hook: ext_hook_sig = None,
|
| 50 |
+
) -> None: ...
|
| 51 |
+
@overload
|
| 52 |
+
def __init__(
|
| 53 |
+
self: Decoder[Any],
|
| 54 |
+
type: Any = ...,
|
| 55 |
+
*,
|
| 56 |
+
strict: bool = True,
|
| 57 |
+
dec_hook: dec_hook_sig = None,
|
| 58 |
+
ext_hook: ext_hook_sig = None,
|
| 59 |
+
) -> None: ...
|
| 60 |
+
def decode(self, buf: Buffer, /) -> T: ...
|
| 61 |
+
|
| 62 |
+
class Encoder:
|
| 63 |
+
enc_hook: enc_hook_sig
|
| 64 |
+
decimal_format: Literal["string", "number"]
|
| 65 |
+
uuid_format: Literal["canonical", "hex", "bytes"]
|
| 66 |
+
order: Literal[None, "deterministic", "sorted"]
|
| 67 |
+
def __init__(
|
| 68 |
+
self,
|
| 69 |
+
*,
|
| 70 |
+
enc_hook: enc_hook_sig = None,
|
| 71 |
+
decimal_format: Literal["string", "number"] = "string",
|
| 72 |
+
uuid_format: Literal["canonical", "hex", "bytes"] = "canonical",
|
| 73 |
+
order: Literal[None, "deterministic", "sorted"] = None,
|
| 74 |
+
): ...
|
| 75 |
+
def encode(self, obj: Any, /) -> bytes: ...
|
| 76 |
+
def encode_into(
|
| 77 |
+
self, obj: Any, buffer: bytearray, offset: Optional[int] = 0, /
|
| 78 |
+
) -> None: ...
|
| 79 |
+
|
| 80 |
+
@overload
|
| 81 |
+
def decode(
|
| 82 |
+
buf: Buffer,
|
| 83 |
+
/,
|
| 84 |
+
*,
|
| 85 |
+
strict: bool = True,
|
| 86 |
+
dec_hook: dec_hook_sig = None,
|
| 87 |
+
ext_hook: ext_hook_sig = None,
|
| 88 |
+
) -> Any: ...
|
| 89 |
+
@overload
|
| 90 |
+
def decode(
|
| 91 |
+
buf: Buffer,
|
| 92 |
+
/,
|
| 93 |
+
*,
|
| 94 |
+
type: Type[T] = ...,
|
| 95 |
+
strict: bool = True,
|
| 96 |
+
dec_hook: dec_hook_sig = None,
|
| 97 |
+
ext_hook: ext_hook_sig = None,
|
| 98 |
+
) -> T: ...
|
| 99 |
+
@overload
|
| 100 |
+
def decode(
|
| 101 |
+
buf: Buffer,
|
| 102 |
+
/,
|
| 103 |
+
*,
|
| 104 |
+
type: Any = ...,
|
| 105 |
+
strict: bool = True,
|
| 106 |
+
dec_hook: dec_hook_sig = None,
|
| 107 |
+
ext_hook: ext_hook_sig = None,
|
| 108 |
+
) -> Any: ...
|
| 109 |
+
def encode(obj: Any, /, *, enc_hook: enc_hook_sig = None, order: Literal[None, "deterministic", "sorted"] = None) -> bytes: ...
|
.venv/lib/python3.11/site-packages/msgspec/py.typed
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/msgspec/structs.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from typing import Any
|
| 4 |
+
|
| 5 |
+
from . import NODEFAULT, Struct, field
|
| 6 |
+
from ._core import ( # noqa
|
| 7 |
+
Factory as _Factory,
|
| 8 |
+
StructConfig,
|
| 9 |
+
asdict,
|
| 10 |
+
astuple,
|
| 11 |
+
replace,
|
| 12 |
+
force_setattr,
|
| 13 |
+
)
|
| 14 |
+
from ._utils import get_class_annotations as _get_class_annotations
|
| 15 |
+
|
| 16 |
+
__all__ = (
|
| 17 |
+
"FieldInfo",
|
| 18 |
+
"StructConfig",
|
| 19 |
+
"asdict",
|
| 20 |
+
"astuple",
|
| 21 |
+
"fields",
|
| 22 |
+
"force_setattr",
|
| 23 |
+
"replace",
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def __dir__():
|
| 28 |
+
return __all__
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class FieldInfo(Struct):
|
| 32 |
+
"""A record describing a field in a struct type.
|
| 33 |
+
|
| 34 |
+
Parameters
|
| 35 |
+
----------
|
| 36 |
+
name: str
|
| 37 |
+
The field name as seen by Python code (e.g. ``field_one``).
|
| 38 |
+
encode_name: str
|
| 39 |
+
The name used when encoding/decoding the field. This may differ if
|
| 40 |
+
the field is renamed (e.g. ``fieldOne``).
|
| 41 |
+
type: Any
|
| 42 |
+
The full field type annotation.
|
| 43 |
+
default: Any, optional
|
| 44 |
+
A default value for the field. Will be `NODEFAULT` if no default value
|
| 45 |
+
is set.
|
| 46 |
+
default_factory: Any, optional
|
| 47 |
+
A callable that creates a default value for the field. Will be
|
| 48 |
+
`NODEFAULT` if no ``default_factory`` is set.
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
name: str
|
| 52 |
+
encode_name: str
|
| 53 |
+
type: Any
|
| 54 |
+
default: Any = field(default_factory=lambda: NODEFAULT)
|
| 55 |
+
default_factory: Any = field(default_factory=lambda: NODEFAULT)
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
def required(self) -> bool:
|
| 59 |
+
"""A helper for checking whether a field is required"""
|
| 60 |
+
return self.default is NODEFAULT and self.default_factory is NODEFAULT
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def fields(type_or_instance: Struct | type[Struct]) -> tuple[FieldInfo]:
|
| 64 |
+
"""Get information about the fields in a Struct.
|
| 65 |
+
|
| 66 |
+
Parameters
|
| 67 |
+
----------
|
| 68 |
+
type_or_instance:
|
| 69 |
+
A struct type or instance.
|
| 70 |
+
|
| 71 |
+
Returns
|
| 72 |
+
-------
|
| 73 |
+
tuple[FieldInfo]
|
| 74 |
+
"""
|
| 75 |
+
if isinstance(type_or_instance, Struct):
|
| 76 |
+
annotated_cls = cls = type(type_or_instance)
|
| 77 |
+
else:
|
| 78 |
+
annotated_cls = type_or_instance
|
| 79 |
+
cls = getattr(type_or_instance, "__origin__", type_or_instance)
|
| 80 |
+
if not (isinstance(cls, type) and issubclass(cls, Struct)):
|
| 81 |
+
raise TypeError("Must be called with a struct type or instance")
|
| 82 |
+
|
| 83 |
+
hints = _get_class_annotations(annotated_cls)
|
| 84 |
+
npos = len(cls.__struct_fields__) - len(cls.__struct_defaults__)
|
| 85 |
+
fields = []
|
| 86 |
+
for name, encode_name, default_obj in zip(
|
| 87 |
+
cls.__struct_fields__,
|
| 88 |
+
cls.__struct_encode_fields__,
|
| 89 |
+
(NODEFAULT,) * npos + cls.__struct_defaults__,
|
| 90 |
+
):
|
| 91 |
+
default = default_factory = NODEFAULT
|
| 92 |
+
if isinstance(default_obj, _Factory):
|
| 93 |
+
default_factory = default_obj.factory
|
| 94 |
+
elif default_obj is not NODEFAULT:
|
| 95 |
+
default = default_obj
|
| 96 |
+
|
| 97 |
+
field = FieldInfo(
|
| 98 |
+
name=name,
|
| 99 |
+
encode_name=encode_name,
|
| 100 |
+
type=hints[name],
|
| 101 |
+
default=default,
|
| 102 |
+
default_factory=default_factory,
|
| 103 |
+
)
|
| 104 |
+
fields.append(field)
|
| 105 |
+
|
| 106 |
+
return tuple(fields)
|
.venv/lib/python3.11/site-packages/msgspec/structs.pyi
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, TypeVar, Union
|
| 2 |
+
|
| 3 |
+
from . import NODEFAULT, Struct
|
| 4 |
+
|
| 5 |
+
S = TypeVar("S", bound=Struct)
|
| 6 |
+
|
| 7 |
+
def replace(struct: S, /, **changes: Any) -> S: ...
|
| 8 |
+
def asdict(struct: Struct) -> dict[str, Any]: ...
|
| 9 |
+
def astuple(struct: Struct) -> tuple[Any, ...]: ...
|
| 10 |
+
def force_setattr(struct: Struct, name: str, value: Any) -> None: ...
|
| 11 |
+
|
| 12 |
+
class StructConfig:
|
| 13 |
+
frozen: bool
|
| 14 |
+
eq: bool
|
| 15 |
+
order: bool
|
| 16 |
+
array_like: bool
|
| 17 |
+
gc: bool
|
| 18 |
+
repr_omit_defaults: bool
|
| 19 |
+
omit_defaults: bool
|
| 20 |
+
forbid_unknown_fields: bool
|
| 21 |
+
weakref: bool
|
| 22 |
+
dict: bool
|
| 23 |
+
cache_hash: bool
|
| 24 |
+
tag: Union[str, int, None]
|
| 25 |
+
tag_field: Union[str, None]
|
| 26 |
+
|
| 27 |
+
class FieldInfo(Struct):
|
| 28 |
+
name: str
|
| 29 |
+
encode_name: str
|
| 30 |
+
type: Any
|
| 31 |
+
default: Any = NODEFAULT
|
| 32 |
+
default_factory: Any = NODEFAULT
|
| 33 |
+
|
| 34 |
+
@property
|
| 35 |
+
def required(self) -> bool: ...
|
| 36 |
+
|
| 37 |
+
def fields(type_or_instance: Struct | type[Struct]) -> tuple[FieldInfo]: ...
|