Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- python/Lib/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/compat/__pycache__/__init__.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/compat/__pycache__/py310.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/compat/__pycache__/py311.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/compat/__pycache__/py312.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/compat/__pycache__/py39.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/__pycache__/__init__.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/__pycache__/_apply_pyprojecttoml.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/__pycache__/expand.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/__pycache__/pyprojecttoml.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/__pycache__/setupcfg.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/NOTICE +438 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__init__.py +34 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/__init__.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/error_reporting.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/extra_validations.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/fastjsonschema_exceptions.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/formats.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/error_reporting.py +338 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/extra_validations.py +151 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py +51 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_validations.py +0 -0
- python/Lib/site-packages/setuptools/config/_validate_pyproject/formats.py +464 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/__init__.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_build_clib.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_build_ext.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_build_meta.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_build_py.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_config_discovery.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_core_metadata.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_depends.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_develop.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_dist.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_dist_info.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_distutils_adoption.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_editable_install.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_egg_info.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_extern.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_find_packages.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_find_py_modules.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_glob.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_install_scripts.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_logging.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_manifest.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_namespaces.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_scripts.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_sdist.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_setopt.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_setuptools.cpython-313.pyc +0 -0
- python/Lib/site-packages/setuptools/tests/__pycache__/test_shutil_wrapper.cpython-313.pyc +0 -0
python/Lib/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-313.pyc
ADDED
|
Binary file (24.7 kB). View file
|
|
|
python/Lib/site-packages/setuptools/compat/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (173 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/compat/__pycache__/py310.cpython-313.pyc
ADDED
|
Binary file (777 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/compat/__pycache__/py311.cpython-313.pyc
ADDED
|
Binary file (1.43 kB). View file
|
|
|
python/Lib/site-packages/setuptools/compat/__pycache__/py312.cpython-313.pyc
ADDED
|
Binary file (458 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/compat/__pycache__/py39.cpython-313.pyc
ADDED
|
Binary file (304 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/config/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (2 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/__pycache__/_apply_pyprojecttoml.cpython-313.pyc
ADDED
|
Binary file (26 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/__pycache__/expand.cpython-313.pyc
ADDED
|
Binary file (24.8 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/__pycache__/pyprojecttoml.cpython-313.pyc
ADDED
|
Binary file (24.4 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/__pycache__/setupcfg.cpython-313.pyc
ADDED
|
Binary file (32.8 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/NOTICE
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The code contained in this directory was automatically generated using the
|
| 2 |
+
following command:
|
| 3 |
+
|
| 4 |
+
python -m validate_pyproject.pre_compile --output-dir=setuptools/config/_validate_pyproject --enable-plugins setuptools distutils --very-verbose -t distutils=setuptools/config/distutils.schema.json -t setuptools=setuptools/config/setuptools.schema.json
|
| 5 |
+
|
| 6 |
+
Please avoid changing it manually.
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
You can report issues or suggest changes directly to `validate-pyproject`
|
| 10 |
+
(or to the relevant plugin repository)
|
| 11 |
+
|
| 12 |
+
- https://github.com/abravalheri/validate-pyproject/issues
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
***
|
| 16 |
+
|
| 17 |
+
The following files include code from opensource projects
|
| 18 |
+
(either as direct copies or modified versions):
|
| 19 |
+
|
| 20 |
+
- `fastjsonschema_exceptions.py`:
|
| 21 |
+
- project: `fastjsonschema` - licensed under BSD-3-Clause
|
| 22 |
+
(https://github.com/horejsek/python-fastjsonschema)
|
| 23 |
+
- `extra_validations.py` and `format.py`, `error_reporting.py`:
|
| 24 |
+
- project: `validate-pyproject` - licensed under MPL-2.0
|
| 25 |
+
(https://github.com/abravalheri/validate-pyproject)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
Additionally the following files are automatically generated by tools provided
|
| 29 |
+
by the same projects:
|
| 30 |
+
|
| 31 |
+
- `__init__.py`
|
| 32 |
+
- `fastjsonschema_validations.py`
|
| 33 |
+
|
| 34 |
+
The relevant copyright notes and licenses are included below.
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
***
|
| 38 |
+
|
| 39 |
+
`fastjsonschema`
|
| 40 |
+
================
|
| 41 |
+
|
| 42 |
+
Copyright (c) 2018, Michal Horejsek
|
| 43 |
+
All rights reserved.
|
| 44 |
+
|
| 45 |
+
Redistribution and use in source and binary forms, with or without modification,
|
| 46 |
+
are permitted provided that the following conditions are met:
|
| 47 |
+
|
| 48 |
+
Redistributions of source code must retain the above copyright notice, this
|
| 49 |
+
list of conditions and the following disclaimer.
|
| 50 |
+
|
| 51 |
+
Redistributions in binary form must reproduce the above copyright notice, this
|
| 52 |
+
list of conditions and the following disclaimer in the documentation and/or
|
| 53 |
+
other materials provided with the distribution.
|
| 54 |
+
|
| 55 |
+
Neither the name of the {organization} nor the names of its
|
| 56 |
+
contributors may be used to endorse or promote products derived from
|
| 57 |
+
this software without specific prior written permission.
|
| 58 |
+
|
| 59 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
| 60 |
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 61 |
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 62 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
| 63 |
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
| 64 |
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
| 65 |
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
| 66 |
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 67 |
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 68 |
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
***
|
| 73 |
+
|
| 74 |
+
`validate-pyproject`
|
| 75 |
+
====================
|
| 76 |
+
|
| 77 |
+
Mozilla Public License, version 2.0
|
| 78 |
+
|
| 79 |
+
1. Definitions
|
| 80 |
+
|
| 81 |
+
1.1. "Contributor"
|
| 82 |
+
|
| 83 |
+
means each individual or legal entity that creates, contributes to the
|
| 84 |
+
creation of, or owns Covered Software.
|
| 85 |
+
|
| 86 |
+
1.2. "Contributor Version"
|
| 87 |
+
|
| 88 |
+
means the combination of the Contributions of others (if any) used by a
|
| 89 |
+
Contributor and that particular Contributor's Contribution.
|
| 90 |
+
|
| 91 |
+
1.3. "Contribution"
|
| 92 |
+
|
| 93 |
+
means Covered Software of a particular Contributor.
|
| 94 |
+
|
| 95 |
+
1.4. "Covered Software"
|
| 96 |
+
|
| 97 |
+
means Source Code Form to which the initial Contributor has attached the
|
| 98 |
+
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
| 99 |
+
Modifications of such Source Code Form, in each case including portions
|
| 100 |
+
thereof.
|
| 101 |
+
|
| 102 |
+
1.5. "Incompatible With Secondary Licenses"
|
| 103 |
+
means
|
| 104 |
+
|
| 105 |
+
a. that the initial Contributor has attached the notice described in
|
| 106 |
+
Exhibit B to the Covered Software; or
|
| 107 |
+
|
| 108 |
+
b. that the Covered Software was made available under the terms of
|
| 109 |
+
version 1.1 or earlier of the License, but not also under the terms of
|
| 110 |
+
a Secondary License.
|
| 111 |
+
|
| 112 |
+
1.6. "Executable Form"
|
| 113 |
+
|
| 114 |
+
means any form of the work other than Source Code Form.
|
| 115 |
+
|
| 116 |
+
1.7. "Larger Work"
|
| 117 |
+
|
| 118 |
+
means a work that combines Covered Software with other material, in a
|
| 119 |
+
separate file or files, that is not Covered Software.
|
| 120 |
+
|
| 121 |
+
1.8. "License"
|
| 122 |
+
|
| 123 |
+
means this document.
|
| 124 |
+
|
| 125 |
+
1.9. "Licensable"
|
| 126 |
+
|
| 127 |
+
means having the right to grant, to the maximum extent possible, whether
|
| 128 |
+
at the time of the initial grant or subsequently, any and all of the
|
| 129 |
+
rights conveyed by this License.
|
| 130 |
+
|
| 131 |
+
1.10. "Modifications"
|
| 132 |
+
|
| 133 |
+
means any of the following:
|
| 134 |
+
|
| 135 |
+
a. any file in Source Code Form that results from an addition to,
|
| 136 |
+
deletion from, or modification of the contents of Covered Software; or
|
| 137 |
+
|
| 138 |
+
b. any new file in Source Code Form that contains any Covered Software.
|
| 139 |
+
|
| 140 |
+
1.11. "Patent Claims" of a Contributor
|
| 141 |
+
|
| 142 |
+
means any patent claim(s), including without limitation, method,
|
| 143 |
+
process, and apparatus claims, in any patent Licensable by such
|
| 144 |
+
Contributor that would be infringed, but for the grant of the License,
|
| 145 |
+
by the making, using, selling, offering for sale, having made, import,
|
| 146 |
+
or transfer of either its Contributions or its Contributor Version.
|
| 147 |
+
|
| 148 |
+
1.12. "Secondary License"
|
| 149 |
+
|
| 150 |
+
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
| 151 |
+
General Public License, Version 2.1, the GNU Affero General Public
|
| 152 |
+
License, Version 3.0, or any later versions of those licenses.
|
| 153 |
+
|
| 154 |
+
1.13. "Source Code Form"
|
| 155 |
+
|
| 156 |
+
means the form of the work preferred for making modifications.
|
| 157 |
+
|
| 158 |
+
1.14. "You" (or "Your")
|
| 159 |
+
|
| 160 |
+
means an individual or a legal entity exercising rights under this
|
| 161 |
+
License. For legal entities, "You" includes any entity that controls, is
|
| 162 |
+
controlled by, or is under common control with You. For purposes of this
|
| 163 |
+
definition, "control" means (a) the power, direct or indirect, to cause
|
| 164 |
+
the direction or management of such entity, whether by contract or
|
| 165 |
+
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
| 166 |
+
outstanding shares or beneficial ownership of such entity.
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
2. License Grants and Conditions
|
| 170 |
+
|
| 171 |
+
2.1. Grants
|
| 172 |
+
|
| 173 |
+
Each Contributor hereby grants You a world-wide, royalty-free,
|
| 174 |
+
non-exclusive license:
|
| 175 |
+
|
| 176 |
+
a. under intellectual property rights (other than patent or trademark)
|
| 177 |
+
Licensable by such Contributor to use, reproduce, make available,
|
| 178 |
+
modify, display, perform, distribute, and otherwise exploit its
|
| 179 |
+
Contributions, either on an unmodified basis, with Modifications, or
|
| 180 |
+
as part of a Larger Work; and
|
| 181 |
+
|
| 182 |
+
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
| 183 |
+
sale, have made, import, and otherwise transfer either its
|
| 184 |
+
Contributions or its Contributor Version.
|
| 185 |
+
|
| 186 |
+
2.2. Effective Date
|
| 187 |
+
|
| 188 |
+
The licenses granted in Section 2.1 with respect to any Contribution
|
| 189 |
+
become effective for each Contribution on the date the Contributor first
|
| 190 |
+
distributes such Contribution.
|
| 191 |
+
|
| 192 |
+
2.3. Limitations on Grant Scope
|
| 193 |
+
|
| 194 |
+
The licenses granted in this Section 2 are the only rights granted under
|
| 195 |
+
this License. No additional rights or licenses will be implied from the
|
| 196 |
+
distribution or licensing of Covered Software under this License.
|
| 197 |
+
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
| 198 |
+
Contributor:
|
| 199 |
+
|
| 200 |
+
a. for any code that a Contributor has removed from Covered Software; or
|
| 201 |
+
|
| 202 |
+
b. for infringements caused by: (i) Your and any other third party's
|
| 203 |
+
modifications of Covered Software, or (ii) the combination of its
|
| 204 |
+
Contributions with other software (except as part of its Contributor
|
| 205 |
+
Version); or
|
| 206 |
+
|
| 207 |
+
c. under Patent Claims infringed by Covered Software in the absence of
|
| 208 |
+
its Contributions.
|
| 209 |
+
|
| 210 |
+
This License does not grant any rights in the trademarks, service marks,
|
| 211 |
+
or logos of any Contributor (except as may be necessary to comply with
|
| 212 |
+
the notice requirements in Section 3.4).
|
| 213 |
+
|
| 214 |
+
2.4. Subsequent Licenses
|
| 215 |
+
|
| 216 |
+
No Contributor makes additional grants as a result of Your choice to
|
| 217 |
+
distribute the Covered Software under a subsequent version of this
|
| 218 |
+
License (see Section 10.2) or under the terms of a Secondary License (if
|
| 219 |
+
permitted under the terms of Section 3.3).
|
| 220 |
+
|
| 221 |
+
2.5. Representation
|
| 222 |
+
|
| 223 |
+
Each Contributor represents that the Contributor believes its
|
| 224 |
+
Contributions are its original creation(s) or it has sufficient rights to
|
| 225 |
+
grant the rights to its Contributions conveyed by this License.
|
| 226 |
+
|
| 227 |
+
2.6. Fair Use
|
| 228 |
+
|
| 229 |
+
This License is not intended to limit any rights You have under
|
| 230 |
+
applicable copyright doctrines of fair use, fair dealing, or other
|
| 231 |
+
equivalents.
|
| 232 |
+
|
| 233 |
+
2.7. Conditions
|
| 234 |
+
|
| 235 |
+
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
| 236 |
+
Section 2.1.
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
3. Responsibilities
|
| 240 |
+
|
| 241 |
+
3.1. Distribution of Source Form
|
| 242 |
+
|
| 243 |
+
All distribution of Covered Software in Source Code Form, including any
|
| 244 |
+
Modifications that You create or to which You contribute, must be under
|
| 245 |
+
the terms of this License. You must inform recipients that the Source
|
| 246 |
+
Code Form of the Covered Software is governed by the terms of this
|
| 247 |
+
License, and how they can obtain a copy of this License. You may not
|
| 248 |
+
attempt to alter or restrict the recipients' rights in the Source Code
|
| 249 |
+
Form.
|
| 250 |
+
|
| 251 |
+
3.2. Distribution of Executable Form
|
| 252 |
+
|
| 253 |
+
If You distribute Covered Software in Executable Form then:
|
| 254 |
+
|
| 255 |
+
a. such Covered Software must also be made available in Source Code Form,
|
| 256 |
+
as described in Section 3.1, and You must inform recipients of the
|
| 257 |
+
Executable Form how they can obtain a copy of such Source Code Form by
|
| 258 |
+
reasonable means in a timely manner, at a charge no more than the cost
|
| 259 |
+
of distribution to the recipient; and
|
| 260 |
+
|
| 261 |
+
b. You may distribute such Executable Form under the terms of this
|
| 262 |
+
License, or sublicense it under different terms, provided that the
|
| 263 |
+
license for the Executable Form does not attempt to limit or alter the
|
| 264 |
+
recipients' rights in the Source Code Form under this License.
|
| 265 |
+
|
| 266 |
+
3.3. Distribution of a Larger Work
|
| 267 |
+
|
| 268 |
+
You may create and distribute a Larger Work under terms of Your choice,
|
| 269 |
+
provided that You also comply with the requirements of this License for
|
| 270 |
+
the Covered Software. If the Larger Work is a combination of Covered
|
| 271 |
+
Software with a work governed by one or more Secondary Licenses, and the
|
| 272 |
+
Covered Software is not Incompatible With Secondary Licenses, this
|
| 273 |
+
License permits You to additionally distribute such Covered Software
|
| 274 |
+
under the terms of such Secondary License(s), so that the recipient of
|
| 275 |
+
the Larger Work may, at their option, further distribute the Covered
|
| 276 |
+
Software under the terms of either this License or such Secondary
|
| 277 |
+
License(s).
|
| 278 |
+
|
| 279 |
+
3.4. Notices
|
| 280 |
+
|
| 281 |
+
You may not remove or alter the substance of any license notices
|
| 282 |
+
(including copyright notices, patent notices, disclaimers of warranty, or
|
| 283 |
+
limitations of liability) contained within the Source Code Form of the
|
| 284 |
+
Covered Software, except that You may alter any license notices to the
|
| 285 |
+
extent required to remedy known factual inaccuracies.
|
| 286 |
+
|
| 287 |
+
3.5. Application of Additional Terms
|
| 288 |
+
|
| 289 |
+
You may choose to offer, and to charge a fee for, warranty, support,
|
| 290 |
+
indemnity or liability obligations to one or more recipients of Covered
|
| 291 |
+
Software. However, You may do so only on Your own behalf, and not on
|
| 292 |
+
behalf of any Contributor. You must make it absolutely clear that any
|
| 293 |
+
such warranty, support, indemnity, or liability obligation is offered by
|
| 294 |
+
You alone, and You hereby agree to indemnify every Contributor for any
|
| 295 |
+
liability incurred by such Contributor as a result of warranty, support,
|
| 296 |
+
indemnity or liability terms You offer. You may include additional
|
| 297 |
+
disclaimers of warranty and limitations of liability specific to any
|
| 298 |
+
jurisdiction.
|
| 299 |
+
|
| 300 |
+
4. Inability to Comply Due to Statute or Regulation
|
| 301 |
+
|
| 302 |
+
If it is impossible for You to comply with any of the terms of this License
|
| 303 |
+
with respect to some or all of the Covered Software due to statute,
|
| 304 |
+
judicial order, or regulation then You must: (a) comply with the terms of
|
| 305 |
+
this License to the maximum extent possible; and (b) describe the
|
| 306 |
+
limitations and the code they affect. Such description must be placed in a
|
| 307 |
+
text file included with all distributions of the Covered Software under
|
| 308 |
+
this License. Except to the extent prohibited by statute or regulation,
|
| 309 |
+
such description must be sufficiently detailed for a recipient of ordinary
|
| 310 |
+
skill to be able to understand it.
|
| 311 |
+
|
| 312 |
+
5. Termination
|
| 313 |
+
|
| 314 |
+
5.1. The rights granted under this License will terminate automatically if You
|
| 315 |
+
fail to comply with any of its terms. However, if You become compliant,
|
| 316 |
+
then the rights granted under this License from a particular Contributor
|
| 317 |
+
are reinstated (a) provisionally, unless and until such Contributor
|
| 318 |
+
explicitly and finally terminates Your grants, and (b) on an ongoing
|
| 319 |
+
basis, if such Contributor fails to notify You of the non-compliance by
|
| 320 |
+
some reasonable means prior to 60 days after You have come back into
|
| 321 |
+
compliance. Moreover, Your grants from a particular Contributor are
|
| 322 |
+
reinstated on an ongoing basis if such Contributor notifies You of the
|
| 323 |
+
non-compliance by some reasonable means, this is the first time You have
|
| 324 |
+
received notice of non-compliance with this License from such
|
| 325 |
+
Contributor, and You become compliant prior to 30 days after Your receipt
|
| 326 |
+
of the notice.
|
| 327 |
+
|
| 328 |
+
5.2. If You initiate litigation against any entity by asserting a patent
|
| 329 |
+
infringement claim (excluding declaratory judgment actions,
|
| 330 |
+
counter-claims, and cross-claims) alleging that a Contributor Version
|
| 331 |
+
directly or indirectly infringes any patent, then the rights granted to
|
| 332 |
+
You by any and all Contributors for the Covered Software under Section
|
| 333 |
+
2.1 of this License shall terminate.
|
| 334 |
+
|
| 335 |
+
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
| 336 |
+
license agreements (excluding distributors and resellers) which have been
|
| 337 |
+
validly granted by You or Your distributors under this License prior to
|
| 338 |
+
termination shall survive termination.
|
| 339 |
+
|
| 340 |
+
6. Disclaimer of Warranty
|
| 341 |
+
|
| 342 |
+
Covered Software is provided under this License on an "as is" basis,
|
| 343 |
+
without warranty of any kind, either expressed, implied, or statutory,
|
| 344 |
+
including, without limitation, warranties that the Covered Software is free
|
| 345 |
+
of defects, merchantable, fit for a particular purpose or non-infringing.
|
| 346 |
+
The entire risk as to the quality and performance of the Covered Software
|
| 347 |
+
is with You. Should any Covered Software prove defective in any respect,
|
| 348 |
+
You (not any Contributor) assume the cost of any necessary servicing,
|
| 349 |
+
repair, or correction. This disclaimer of warranty constitutes an essential
|
| 350 |
+
part of this License. No use of any Covered Software is authorized under
|
| 351 |
+
this License except under this disclaimer.
|
| 352 |
+
|
| 353 |
+
7. Limitation of Liability
|
| 354 |
+
|
| 355 |
+
Under no circumstances and under no legal theory, whether tort (including
|
| 356 |
+
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
| 357 |
+
distributes Covered Software as permitted above, be liable to You for any
|
| 358 |
+
direct, indirect, special, incidental, or consequential damages of any
|
| 359 |
+
character including, without limitation, damages for lost profits, loss of
|
| 360 |
+
goodwill, work stoppage, computer failure or malfunction, or any and all
|
| 361 |
+
other commercial damages or losses, even if such party shall have been
|
| 362 |
+
informed of the possibility of such damages. This limitation of liability
|
| 363 |
+
shall not apply to liability for death or personal injury resulting from
|
| 364 |
+
such party's negligence to the extent applicable law prohibits such
|
| 365 |
+
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
| 366 |
+
incidental or consequential damages, so this exclusion and limitation may
|
| 367 |
+
not apply to You.
|
| 368 |
+
|
| 369 |
+
8. Litigation
|
| 370 |
+
|
| 371 |
+
Any litigation relating to this License may be brought only in the courts
|
| 372 |
+
of a jurisdiction where the defendant maintains its principal place of
|
| 373 |
+
business and such litigation shall be governed by laws of that
|
| 374 |
+
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
| 375 |
+
in this Section shall prevent a party's ability to bring cross-claims or
|
| 376 |
+
counter-claims.
|
| 377 |
+
|
| 378 |
+
9. Miscellaneous
|
| 379 |
+
|
| 380 |
+
This License represents the complete agreement concerning the subject
|
| 381 |
+
matter hereof. If any provision of this License is held to be
|
| 382 |
+
unenforceable, such provision shall be reformed only to the extent
|
| 383 |
+
necessary to make it enforceable. Any law or regulation which provides that
|
| 384 |
+
the language of a contract shall be construed against the drafter shall not
|
| 385 |
+
be used to construe this License against a Contributor.
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
10. Versions of the License
|
| 389 |
+
|
| 390 |
+
10.1. New Versions
|
| 391 |
+
|
| 392 |
+
Mozilla Foundation is the license steward. Except as provided in Section
|
| 393 |
+
10.3, no one other than the license steward has the right to modify or
|
| 394 |
+
publish new versions of this License. Each version will be given a
|
| 395 |
+
distinguishing version number.
|
| 396 |
+
|
| 397 |
+
10.2. Effect of New Versions
|
| 398 |
+
|
| 399 |
+
You may distribute the Covered Software under the terms of the version
|
| 400 |
+
of the License under which You originally received the Covered Software,
|
| 401 |
+
or under the terms of any subsequent version published by the license
|
| 402 |
+
steward.
|
| 403 |
+
|
| 404 |
+
10.3. Modified Versions
|
| 405 |
+
|
| 406 |
+
If you create software not governed by this License, and you want to
|
| 407 |
+
create a new license for such software, you may create and use a
|
| 408 |
+
modified version of this License if you rename the license and remove
|
| 409 |
+
any references to the name of the license steward (except to note that
|
| 410 |
+
such modified license differs from this License).
|
| 411 |
+
|
| 412 |
+
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
| 413 |
+
Licenses If You choose to distribute Source Code Form that is
|
| 414 |
+
Incompatible With Secondary Licenses under the terms of this version of
|
| 415 |
+
the License, the notice described in Exhibit B of this License must be
|
| 416 |
+
attached.
|
| 417 |
+
|
| 418 |
+
Exhibit A - Source Code Form License Notice
|
| 419 |
+
|
| 420 |
+
This Source Code Form is subject to the
|
| 421 |
+
terms of the Mozilla Public License, v.
|
| 422 |
+
2.0. If a copy of the MPL was not
|
| 423 |
+
distributed with this file, You can
|
| 424 |
+
obtain one at
|
| 425 |
+
https://mozilla.org/MPL/2.0/.
|
| 426 |
+
|
| 427 |
+
If it is not possible or desirable to put the notice in a particular file,
|
| 428 |
+
then You may include the notice in a location (such as a LICENSE file in a
|
| 429 |
+
relevant directory) where a recipient would be likely to look for such a
|
| 430 |
+
notice.
|
| 431 |
+
|
| 432 |
+
You may add additional accurate notices of copyright ownership.
|
| 433 |
+
|
| 434 |
+
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
| 435 |
+
|
| 436 |
+
This Source Code Form is "Incompatible
|
| 437 |
+
With Secondary Licenses", as defined by
|
| 438 |
+
the Mozilla Public License, v. 2.0.
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from functools import reduce
|
| 2 |
+
from typing import Any, Callable, Dict
|
| 3 |
+
|
| 4 |
+
from . import formats
|
| 5 |
+
from .error_reporting import detailed_errors, ValidationError
|
| 6 |
+
from .extra_validations import EXTRA_VALIDATIONS
|
| 7 |
+
from .fastjsonschema_exceptions import JsonSchemaException, JsonSchemaValueException
|
| 8 |
+
from .fastjsonschema_validations import validate as _validate
|
| 9 |
+
|
| 10 |
+
__all__ = [
|
| 11 |
+
"validate",
|
| 12 |
+
"FORMAT_FUNCTIONS",
|
| 13 |
+
"EXTRA_VALIDATIONS",
|
| 14 |
+
"ValidationError",
|
| 15 |
+
"JsonSchemaException",
|
| 16 |
+
"JsonSchemaValueException",
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
FORMAT_FUNCTIONS: Dict[str, Callable[[str], bool]] = {
|
| 21 |
+
fn.__name__.replace("_", "-"): fn
|
| 22 |
+
for fn in formats.__dict__.values()
|
| 23 |
+
if callable(fn) and not fn.__name__.startswith("_")
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def validate(data: Any) -> bool:
|
| 28 |
+
"""Validate the given ``data`` object using JSON Schema
|
| 29 |
+
This function raises ``ValidationError`` if ``data`` is invalid.
|
| 30 |
+
"""
|
| 31 |
+
with detailed_errors():
|
| 32 |
+
_validate(data, custom_formats=FORMAT_FUNCTIONS)
|
| 33 |
+
reduce(lambda acc, fn: fn(acc), EXTRA_VALIDATIONS, data)
|
| 34 |
+
return True
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (1.9 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/error_reporting.cpython-313.pyc
ADDED
|
Binary file (18.5 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/extra_validations.cpython-313.pyc
ADDED
|
Binary file (6.03 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/fastjsonschema_exceptions.cpython-313.pyc
ADDED
|
Binary file (2.91 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/__pycache__/formats.cpython-313.pyc
ADDED
|
Binary file (20.5 kB). View file
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/error_reporting.py
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import io
|
| 4 |
+
import json
|
| 5 |
+
import logging
|
| 6 |
+
import os
|
| 7 |
+
import re
|
| 8 |
+
import typing
|
| 9 |
+
from contextlib import contextmanager
|
| 10 |
+
from textwrap import indent, wrap
|
| 11 |
+
from typing import Any, Generator, Iterator, Sequence
|
| 12 |
+
|
| 13 |
+
from .fastjsonschema_exceptions import JsonSchemaValueException
|
| 14 |
+
|
| 15 |
+
if typing.TYPE_CHECKING:
|
| 16 |
+
import sys
|
| 17 |
+
|
| 18 |
+
if sys.version_info < (3, 11):
|
| 19 |
+
from typing_extensions import Self
|
| 20 |
+
else:
|
| 21 |
+
from typing import Self
|
| 22 |
+
|
| 23 |
+
_logger = logging.getLogger(__name__)
|
| 24 |
+
|
| 25 |
+
_MESSAGE_REPLACEMENTS = {
|
| 26 |
+
"must be named by propertyName definition": "keys must be named by",
|
| 27 |
+
"one of contains definition": "at least one item that matches",
|
| 28 |
+
" same as const definition:": "",
|
| 29 |
+
"only specified items": "only items matching the definition",
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
_SKIP_DETAILS = (
|
| 33 |
+
"must not be empty",
|
| 34 |
+
"is always invalid",
|
| 35 |
+
"must not be there",
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
_NEED_DETAILS = {"anyOf", "oneOf", "allOf", "contains", "propertyNames", "not", "items"}
|
| 39 |
+
|
| 40 |
+
_CAMEL_CASE_SPLITTER = re.compile(r"\W+|([A-Z][^A-Z\W]*)")
|
| 41 |
+
_IDENTIFIER = re.compile(r"^[\w_]+$", re.IGNORECASE)
|
| 42 |
+
|
| 43 |
+
_TOML_JARGON = {
|
| 44 |
+
"object": "table",
|
| 45 |
+
"property": "key",
|
| 46 |
+
"properties": "keys",
|
| 47 |
+
"property names": "keys",
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
_FORMATS_HELP = """
|
| 51 |
+
For more details about `format` see
|
| 52 |
+
https://validate-pyproject.readthedocs.io/en/latest/api/validate_pyproject.formats.html
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class ValidationError(JsonSchemaValueException):
|
| 57 |
+
"""Report violations of a given JSON schema.
|
| 58 |
+
|
| 59 |
+
This class extends :exc:`~fastjsonschema.JsonSchemaValueException`
|
| 60 |
+
by adding the following properties:
|
| 61 |
+
|
| 62 |
+
- ``summary``: an improved version of the ``JsonSchemaValueException`` error message
|
| 63 |
+
with only the necessary information)
|
| 64 |
+
|
| 65 |
+
- ``details``: more contextual information about the error like the failing schema
|
| 66 |
+
itself and the value that violates the schema.
|
| 67 |
+
|
| 68 |
+
Depending on the level of the verbosity of the ``logging`` configuration
|
| 69 |
+
the exception message will be only ``summary`` (default) or a combination of
|
| 70 |
+
``summary`` and ``details`` (when the logging level is set to :obj:`logging.DEBUG`).
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
summary = ""
|
| 74 |
+
details = ""
|
| 75 |
+
_original_message = ""
|
| 76 |
+
|
| 77 |
+
@classmethod
|
| 78 |
+
def _from_jsonschema(cls, ex: JsonSchemaValueException) -> Self:
|
| 79 |
+
formatter = _ErrorFormatting(ex)
|
| 80 |
+
obj = cls(str(formatter), ex.value, formatter.name, ex.definition, ex.rule)
|
| 81 |
+
debug_code = os.getenv("JSONSCHEMA_DEBUG_CODE_GENERATION", "false").lower()
|
| 82 |
+
if debug_code != "false": # pragma: no cover
|
| 83 |
+
obj.__cause__, obj.__traceback__ = ex.__cause__, ex.__traceback__
|
| 84 |
+
obj._original_message = ex.message
|
| 85 |
+
obj.summary = formatter.summary
|
| 86 |
+
obj.details = formatter.details
|
| 87 |
+
return obj
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
@contextmanager
|
| 91 |
+
def detailed_errors() -> Generator[None, None, None]:
|
| 92 |
+
try:
|
| 93 |
+
yield
|
| 94 |
+
except JsonSchemaValueException as ex:
|
| 95 |
+
raise ValidationError._from_jsonschema(ex) from None
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
class _ErrorFormatting:
|
| 99 |
+
def __init__(self, ex: JsonSchemaValueException):
|
| 100 |
+
self.ex = ex
|
| 101 |
+
self.name = f"`{self._simplify_name(ex.name)}`"
|
| 102 |
+
self._original_message: str = self.ex.message.replace(ex.name, self.name)
|
| 103 |
+
self._summary = ""
|
| 104 |
+
self._details = ""
|
| 105 |
+
|
| 106 |
+
def __str__(self) -> str:
|
| 107 |
+
if _logger.getEffectiveLevel() <= logging.DEBUG and self.details:
|
| 108 |
+
return f"{self.summary}\n\n{self.details}"
|
| 109 |
+
|
| 110 |
+
return self.summary
|
| 111 |
+
|
| 112 |
+
@property
|
| 113 |
+
def summary(self) -> str:
|
| 114 |
+
if not self._summary:
|
| 115 |
+
self._summary = self._expand_summary()
|
| 116 |
+
|
| 117 |
+
return self._summary
|
| 118 |
+
|
| 119 |
+
@property
|
| 120 |
+
def details(self) -> str:
|
| 121 |
+
if not self._details:
|
| 122 |
+
self._details = self._expand_details()
|
| 123 |
+
|
| 124 |
+
return self._details
|
| 125 |
+
|
| 126 |
+
@staticmethod
|
| 127 |
+
def _simplify_name(name: str) -> str:
|
| 128 |
+
x = len("data.")
|
| 129 |
+
return name[x:] if name.startswith("data.") else name
|
| 130 |
+
|
| 131 |
+
def _expand_summary(self) -> str:
|
| 132 |
+
msg = self._original_message
|
| 133 |
+
|
| 134 |
+
for bad, repl in _MESSAGE_REPLACEMENTS.items():
|
| 135 |
+
msg = msg.replace(bad, repl)
|
| 136 |
+
|
| 137 |
+
if any(substring in msg for substring in _SKIP_DETAILS):
|
| 138 |
+
return msg
|
| 139 |
+
|
| 140 |
+
schema = self.ex.rule_definition
|
| 141 |
+
if self.ex.rule in _NEED_DETAILS and schema:
|
| 142 |
+
summary = _SummaryWriter(_TOML_JARGON)
|
| 143 |
+
return f"{msg}:\n\n{indent(summary(schema), ' ')}"
|
| 144 |
+
|
| 145 |
+
return msg
|
| 146 |
+
|
| 147 |
+
def _expand_details(self) -> str:
|
| 148 |
+
optional = []
|
| 149 |
+
definition = self.ex.definition or {}
|
| 150 |
+
desc_lines = definition.pop("$$description", [])
|
| 151 |
+
desc = definition.pop("description", None) or " ".join(desc_lines)
|
| 152 |
+
if desc:
|
| 153 |
+
description = "\n".join(
|
| 154 |
+
wrap(
|
| 155 |
+
desc,
|
| 156 |
+
width=80,
|
| 157 |
+
initial_indent=" ",
|
| 158 |
+
subsequent_indent=" ",
|
| 159 |
+
break_long_words=False,
|
| 160 |
+
)
|
| 161 |
+
)
|
| 162 |
+
optional.append(f"DESCRIPTION:\n{description}")
|
| 163 |
+
schema = json.dumps(definition, indent=4)
|
| 164 |
+
value = json.dumps(self.ex.value, indent=4)
|
| 165 |
+
defaults = [
|
| 166 |
+
f"GIVEN VALUE:\n{indent(value, ' ')}",
|
| 167 |
+
f"OFFENDING RULE: {self.ex.rule!r}",
|
| 168 |
+
f"DEFINITION:\n{indent(schema, ' ')}",
|
| 169 |
+
]
|
| 170 |
+
msg = "\n\n".join(optional + defaults)
|
| 171 |
+
epilog = f"\n{_FORMATS_HELP}" if "format" in msg.lower() else ""
|
| 172 |
+
return msg + epilog
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
class _SummaryWriter:
|
| 176 |
+
_IGNORE = frozenset(("description", "default", "title", "examples"))
|
| 177 |
+
|
| 178 |
+
def __init__(self, jargon: dict[str, str] | None = None):
|
| 179 |
+
self.jargon: dict[str, str] = jargon or {}
|
| 180 |
+
# Clarify confusing terms
|
| 181 |
+
self._terms = {
|
| 182 |
+
"anyOf": "at least one of the following",
|
| 183 |
+
"oneOf": "exactly one of the following",
|
| 184 |
+
"allOf": "all of the following",
|
| 185 |
+
"not": "(*NOT* the following)",
|
| 186 |
+
"prefixItems": f"{self._jargon('items')} (in order)",
|
| 187 |
+
"items": "items",
|
| 188 |
+
"contains": "contains at least one of",
|
| 189 |
+
"propertyNames": (
|
| 190 |
+
f"non-predefined acceptable {self._jargon('property names')}"
|
| 191 |
+
),
|
| 192 |
+
"patternProperties": f"{self._jargon('properties')} named via pattern",
|
| 193 |
+
"const": "predefined value",
|
| 194 |
+
"enum": "one of",
|
| 195 |
+
}
|
| 196 |
+
# Attributes that indicate that the definition is easy and can be done
|
| 197 |
+
# inline (e.g. string and number)
|
| 198 |
+
self._guess_inline_defs = [
|
| 199 |
+
"enum",
|
| 200 |
+
"const",
|
| 201 |
+
"maxLength",
|
| 202 |
+
"minLength",
|
| 203 |
+
"pattern",
|
| 204 |
+
"format",
|
| 205 |
+
"minimum",
|
| 206 |
+
"maximum",
|
| 207 |
+
"exclusiveMinimum",
|
| 208 |
+
"exclusiveMaximum",
|
| 209 |
+
"multipleOf",
|
| 210 |
+
]
|
| 211 |
+
|
| 212 |
+
def _jargon(self, term: str | list[str]) -> str | list[str]:
|
| 213 |
+
if isinstance(term, list):
|
| 214 |
+
return [self.jargon.get(t, t) for t in term]
|
| 215 |
+
return self.jargon.get(term, term)
|
| 216 |
+
|
| 217 |
+
def __call__(
|
| 218 |
+
self,
|
| 219 |
+
schema: dict | list[dict],
|
| 220 |
+
prefix: str = "",
|
| 221 |
+
*,
|
| 222 |
+
_path: Sequence[str] = (),
|
| 223 |
+
) -> str:
|
| 224 |
+
if isinstance(schema, list):
|
| 225 |
+
return self._handle_list(schema, prefix, _path)
|
| 226 |
+
|
| 227 |
+
filtered = self._filter_unecessary(schema, _path)
|
| 228 |
+
simple = self._handle_simple_dict(filtered, _path)
|
| 229 |
+
if simple:
|
| 230 |
+
return f"{prefix}{simple}"
|
| 231 |
+
|
| 232 |
+
child_prefix = self._child_prefix(prefix, " ")
|
| 233 |
+
item_prefix = self._child_prefix(prefix, "- ")
|
| 234 |
+
indent = len(prefix) * " "
|
| 235 |
+
with io.StringIO() as buffer:
|
| 236 |
+
for i, (key, value) in enumerate(filtered.items()):
|
| 237 |
+
child_path = [*_path, key]
|
| 238 |
+
line_prefix = prefix if i == 0 else indent
|
| 239 |
+
buffer.write(f"{line_prefix}{self._label(child_path)}:")
|
| 240 |
+
# ^ just the first item should receive the complete prefix
|
| 241 |
+
if isinstance(value, dict):
|
| 242 |
+
filtered = self._filter_unecessary(value, child_path)
|
| 243 |
+
simple = self._handle_simple_dict(filtered, child_path)
|
| 244 |
+
buffer.write(
|
| 245 |
+
f" {simple}"
|
| 246 |
+
if simple
|
| 247 |
+
else f"\n{self(value, child_prefix, _path=child_path)}"
|
| 248 |
+
)
|
| 249 |
+
elif isinstance(value, list) and (
|
| 250 |
+
key != "type" or self._is_property(child_path)
|
| 251 |
+
):
|
| 252 |
+
children = self._handle_list(value, item_prefix, child_path)
|
| 253 |
+
sep = " " if children.startswith("[") else "\n"
|
| 254 |
+
buffer.write(f"{sep}{children}")
|
| 255 |
+
else:
|
| 256 |
+
buffer.write(f" {self._value(value, child_path)}\n")
|
| 257 |
+
return buffer.getvalue()
|
| 258 |
+
|
| 259 |
+
def _is_unecessary(self, path: Sequence[str]) -> bool:
|
| 260 |
+
if self._is_property(path) or not path: # empty path => instruction @ root
|
| 261 |
+
return False
|
| 262 |
+
key = path[-1]
|
| 263 |
+
return any(key.startswith(k) for k in "$_") or key in self._IGNORE
|
| 264 |
+
|
| 265 |
+
def _filter_unecessary(
|
| 266 |
+
self, schema: dict[str, Any], path: Sequence[str]
|
| 267 |
+
) -> dict[str, Any]:
|
| 268 |
+
return {
|
| 269 |
+
key: value
|
| 270 |
+
for key, value in schema.items()
|
| 271 |
+
if not self._is_unecessary([*path, key])
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
def _handle_simple_dict(self, value: dict, path: Sequence[str]) -> str | None:
|
| 275 |
+
inline = any(p in value for p in self._guess_inline_defs)
|
| 276 |
+
simple = not any(isinstance(v, (list, dict)) for v in value.values())
|
| 277 |
+
if inline or simple:
|
| 278 |
+
return f"{{{', '.join(self._inline_attrs(value, path))}}}\n"
|
| 279 |
+
return None
|
| 280 |
+
|
| 281 |
+
def _handle_list(
|
| 282 |
+
self, schemas: list, prefix: str = "", path: Sequence[str] = ()
|
| 283 |
+
) -> str:
|
| 284 |
+
if self._is_unecessary(path):
|
| 285 |
+
return ""
|
| 286 |
+
|
| 287 |
+
repr_ = repr(schemas)
|
| 288 |
+
if all(not isinstance(e, (dict, list)) for e in schemas) and len(repr_) < 60:
|
| 289 |
+
return f"{repr_}\n"
|
| 290 |
+
|
| 291 |
+
item_prefix = self._child_prefix(prefix, "- ")
|
| 292 |
+
return "".join(
|
| 293 |
+
self(v, item_prefix, _path=[*path, f"[{i}]"]) for i, v in enumerate(schemas)
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
def _is_property(self, path: Sequence[str]) -> bool:
|
| 297 |
+
"""Check if the given path can correspond to an arbitrarily named property"""
|
| 298 |
+
counter = 0
|
| 299 |
+
for key in path[-2::-1]:
|
| 300 |
+
if key not in {"properties", "patternProperties"}:
|
| 301 |
+
break
|
| 302 |
+
counter += 1
|
| 303 |
+
|
| 304 |
+
# If the counter if even, the path correspond to a JSON Schema keyword
|
| 305 |
+
# otherwise it can be any arbitrary string naming a property
|
| 306 |
+
return counter % 2 == 1
|
| 307 |
+
|
| 308 |
+
def _label(self, path: Sequence[str]) -> str:
|
| 309 |
+
*parents, key = path
|
| 310 |
+
if not self._is_property(path):
|
| 311 |
+
norm_key = _separate_terms(key)
|
| 312 |
+
return self._terms.get(key) or " ".join(self._jargon(norm_key))
|
| 313 |
+
|
| 314 |
+
if parents[-1] == "patternProperties":
|
| 315 |
+
return f"(regex {key!r})"
|
| 316 |
+
return repr(key) # property name
|
| 317 |
+
|
| 318 |
+
def _value(self, value: Any, path: Sequence[str]) -> str:
|
| 319 |
+
if path[-1] == "type" and not self._is_property(path):
|
| 320 |
+
type_ = self._jargon(value)
|
| 321 |
+
return f"[{', '.join(type_)}]" if isinstance(type_, list) else type_
|
| 322 |
+
return repr(value)
|
| 323 |
+
|
| 324 |
+
def _inline_attrs(self, schema: dict, path: Sequence[str]) -> Iterator[str]:
|
| 325 |
+
for key, value in schema.items():
|
| 326 |
+
child_path = [*path, key]
|
| 327 |
+
yield f"{self._label(child_path)}: {self._value(value, child_path)}"
|
| 328 |
+
|
| 329 |
+
def _child_prefix(self, parent_prefix: str, child_prefix: str) -> str:
|
| 330 |
+
return len(parent_prefix) * " " + child_prefix
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
def _separate_terms(word: str) -> list[str]:
|
| 334 |
+
"""
|
| 335 |
+
>>> _separate_terms("FooBar-foo")
|
| 336 |
+
['foo', 'bar', 'foo']
|
| 337 |
+
"""
|
| 338 |
+
return [w.lower() for w in _CAMEL_CASE_SPLITTER.split(word) if w]
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/extra_validations.py
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The purpose of this module is implement PEP 621 validations that are
|
| 2 |
+
difficult to express as a JSON Schema (or that are not supported by the current
|
| 3 |
+
JSON Schema library).
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import collections
|
| 7 |
+
import itertools
|
| 8 |
+
from inspect import cleandoc
|
| 9 |
+
from typing import Generator, Iterable, Mapping, TypeVar
|
| 10 |
+
|
| 11 |
+
from .error_reporting import ValidationError
|
| 12 |
+
|
| 13 |
+
T = TypeVar("T", bound=Mapping)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class RedefiningStaticFieldAsDynamic(ValidationError):
|
| 17 |
+
_DESC = """According to PEP 621:
|
| 18 |
+
|
| 19 |
+
Build back-ends MUST raise an error if the metadata specifies a field
|
| 20 |
+
statically as well as being listed in dynamic.
|
| 21 |
+
"""
|
| 22 |
+
__doc__ = _DESC
|
| 23 |
+
_URL = (
|
| 24 |
+
"https://packaging.python.org/en/latest/specifications/pyproject-toml/#dynamic"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class IncludedDependencyGroupMustExist(ValidationError):
|
| 29 |
+
_DESC = """An included dependency group must exist and must not be cyclic.
|
| 30 |
+
"""
|
| 31 |
+
__doc__ = _DESC
|
| 32 |
+
_URL = "https://peps.python.org/pep-0735/"
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class ImportNameCollision(ValidationError):
|
| 36 |
+
_DESC = """According to PEP 794:
|
| 37 |
+
|
| 38 |
+
All import-names and import-namespaces items must be unique.
|
| 39 |
+
"""
|
| 40 |
+
__doc__ = _DESC
|
| 41 |
+
_URL = "https://peps.python.org/pep-0794/"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class ImportNameMissing(ValidationError):
|
| 45 |
+
_DESC = """According to PEP 794:
|
| 46 |
+
|
| 47 |
+
An import name must have all parents listed.
|
| 48 |
+
"""
|
| 49 |
+
__doc__ = _DESC
|
| 50 |
+
_URL = "https://peps.python.org/pep-0794/"
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def validate_project_dynamic(pyproject: T) -> T:
|
| 54 |
+
project_table = pyproject.get("project", {})
|
| 55 |
+
dynamic = project_table.get("dynamic", [])
|
| 56 |
+
|
| 57 |
+
for field in dynamic:
|
| 58 |
+
if field in project_table:
|
| 59 |
+
raise RedefiningStaticFieldAsDynamic(
|
| 60 |
+
message=f"You cannot provide a value for `project.{field}` and "
|
| 61 |
+
"list it under `project.dynamic` at the same time",
|
| 62 |
+
value={
|
| 63 |
+
field: project_table[field],
|
| 64 |
+
"...": " # ...",
|
| 65 |
+
"dynamic": dynamic,
|
| 66 |
+
},
|
| 67 |
+
name=f"data.project.{field}",
|
| 68 |
+
definition={
|
| 69 |
+
"description": cleandoc(RedefiningStaticFieldAsDynamic._DESC),
|
| 70 |
+
"see": RedefiningStaticFieldAsDynamic._URL,
|
| 71 |
+
},
|
| 72 |
+
rule="PEP 621",
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
return pyproject
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def validate_include_depenency(pyproject: T) -> T:
|
| 79 |
+
dependency_groups = pyproject.get("dependency-groups", {})
|
| 80 |
+
for key, value in dependency_groups.items():
|
| 81 |
+
for each in value:
|
| 82 |
+
if (
|
| 83 |
+
isinstance(each, dict)
|
| 84 |
+
and (include_group := each.get("include-group"))
|
| 85 |
+
and include_group not in dependency_groups
|
| 86 |
+
):
|
| 87 |
+
raise IncludedDependencyGroupMustExist(
|
| 88 |
+
message=f"The included dependency group {include_group} doesn't exist",
|
| 89 |
+
value=each,
|
| 90 |
+
name=f"data.dependency_groups.{key}",
|
| 91 |
+
definition={
|
| 92 |
+
"description": cleandoc(IncludedDependencyGroupMustExist._DESC),
|
| 93 |
+
"see": IncludedDependencyGroupMustExist._URL,
|
| 94 |
+
},
|
| 95 |
+
rule="PEP 735",
|
| 96 |
+
)
|
| 97 |
+
# TODO: check for `include-group` cycles (can be conditional to graphlib)
|
| 98 |
+
return pyproject
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def _remove_private(items: Iterable[str]) -> Generator[str, None, None]:
|
| 102 |
+
for item in items:
|
| 103 |
+
yield item.partition(";")[0].rstrip()
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def validate_import_name_issues(pyproject: T) -> T:
|
| 107 |
+
project = pyproject.get("project", {})
|
| 108 |
+
import_names = collections.Counter(_remove_private(project.get("import-names", [])))
|
| 109 |
+
import_namespaces = collections.Counter(
|
| 110 |
+
_remove_private(project.get("import-namespaces", []))
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
duplicated = [k for k, v in (import_names + import_namespaces).items() if v > 1]
|
| 114 |
+
|
| 115 |
+
if duplicated:
|
| 116 |
+
raise ImportNameCollision(
|
| 117 |
+
message="Duplicated names are not allowed in import-names/import-namespaces",
|
| 118 |
+
value=duplicated,
|
| 119 |
+
name="data.project.importnames(paces)",
|
| 120 |
+
definition={
|
| 121 |
+
"description": cleandoc(ImportNameCollision._DESC),
|
| 122 |
+
"see": ImportNameCollision._URL,
|
| 123 |
+
},
|
| 124 |
+
rule="PEP 794",
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
names = frozenset(import_names + import_namespaces)
|
| 128 |
+
for name in names:
|
| 129 |
+
for parent in itertools.accumulate(
|
| 130 |
+
name.split(".")[:-1], lambda a, b: f"{a}.{b}"
|
| 131 |
+
):
|
| 132 |
+
if parent not in names:
|
| 133 |
+
raise ImportNameMissing(
|
| 134 |
+
message="All parents of an import name must also be listed in import-namespace/import-names",
|
| 135 |
+
value=name,
|
| 136 |
+
name="data.project.importnames(paces)",
|
| 137 |
+
definition={
|
| 138 |
+
"description": cleandoc(ImportNameMissing._DESC),
|
| 139 |
+
"see": ImportNameMissing._URL,
|
| 140 |
+
},
|
| 141 |
+
rule="PEP 794",
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
return pyproject
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
EXTRA_VALIDATIONS = (
|
| 148 |
+
validate_project_dynamic,
|
| 149 |
+
validate_include_depenency,
|
| 150 |
+
validate_import_name_issues,
|
| 151 |
+
)
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import re
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
SPLIT_RE = re.compile(r'[\.\[\]]+')
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class JsonSchemaException(ValueError):
|
| 8 |
+
"""
|
| 9 |
+
Base exception of ``fastjsonschema`` library.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class JsonSchemaValueException(JsonSchemaException):
|
| 14 |
+
"""
|
| 15 |
+
Exception raised by validation function. Available properties:
|
| 16 |
+
|
| 17 |
+
* ``message`` containing human-readable information what is wrong (e.g. ``data.property[index] must be smaller than or equal to 42``),
|
| 18 |
+
* invalid ``value`` (e.g. ``60``),
|
| 19 |
+
* ``name`` of a path in the data structure (e.g. ``data.property[index]``),
|
| 20 |
+
* ``path`` as an array in the data structure (e.g. ``['data', 'property', 'index']``),
|
| 21 |
+
* the whole ``definition`` which the ``value`` has to fulfil (e.g. ``{'type': 'number', 'maximum': 42}``),
|
| 22 |
+
* ``rule`` which the ``value`` is breaking (e.g. ``maximum``)
|
| 23 |
+
* and ``rule_definition`` (e.g. ``42``).
|
| 24 |
+
|
| 25 |
+
.. versionchanged:: 2.14.0
|
| 26 |
+
Added all extra properties.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
def __init__(self, message, value=None, name=None, definition=None, rule=None):
|
| 30 |
+
super().__init__(message)
|
| 31 |
+
self.message = message
|
| 32 |
+
self.value = value
|
| 33 |
+
self.name = name
|
| 34 |
+
self.definition = definition
|
| 35 |
+
self.rule = rule
|
| 36 |
+
|
| 37 |
+
@property
|
| 38 |
+
def path(self):
|
| 39 |
+
return [item for item in SPLIT_RE.split(self.name) if item != '']
|
| 40 |
+
|
| 41 |
+
@property
|
| 42 |
+
def rule_definition(self):
|
| 43 |
+
if not self.rule or not self.definition:
|
| 44 |
+
return None
|
| 45 |
+
return self.definition.get(self.rule)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class JsonSchemaDefinitionException(JsonSchemaException):
|
| 49 |
+
"""
|
| 50 |
+
Exception raised by generator of validation function.
|
| 51 |
+
"""
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_validations.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
python/Lib/site-packages/setuptools/config/_validate_pyproject/formats.py
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The functions in this module are used to validate schemas with the
|
| 3 |
+
`format JSON Schema keyword
|
| 4 |
+
<https://json-schema.org/understanding-json-schema/reference/string#format>`_.
|
| 5 |
+
|
| 6 |
+
The correspondence is given by replacing the ``_`` character in the name of the
|
| 7 |
+
function with a ``-`` to obtain the format name and vice versa.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import keyword
|
| 13 |
+
import logging
|
| 14 |
+
import os
|
| 15 |
+
import re
|
| 16 |
+
import string
|
| 17 |
+
import typing
|
| 18 |
+
from itertools import chain as _chain
|
| 19 |
+
|
| 20 |
+
if typing.TYPE_CHECKING:
|
| 21 |
+
import builtins
|
| 22 |
+
|
| 23 |
+
from typing_extensions import Literal
|
| 24 |
+
|
| 25 |
+
_logger = logging.getLogger(__name__)
|
| 26 |
+
|
| 27 |
+
# -------------------------------------------------------------------------------------
|
| 28 |
+
# PEP 440
|
| 29 |
+
|
| 30 |
+
VERSION_PATTERN = r"""
|
| 31 |
+
v?
|
| 32 |
+
(?:
|
| 33 |
+
(?:(?P<epoch>[0-9]+)!)? # epoch
|
| 34 |
+
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
|
| 35 |
+
(?P<pre> # pre-release
|
| 36 |
+
[-_\.]?
|
| 37 |
+
(?P<pre_l>alpha|a|beta|b|preview|pre|c|rc)
|
| 38 |
+
[-_\.]?
|
| 39 |
+
(?P<pre_n>[0-9]+)?
|
| 40 |
+
)?
|
| 41 |
+
(?P<post> # post release
|
| 42 |
+
(?:-(?P<post_n1>[0-9]+))
|
| 43 |
+
|
|
| 44 |
+
(?:
|
| 45 |
+
[-_\.]?
|
| 46 |
+
(?P<post_l>post|rev|r)
|
| 47 |
+
[-_\.]?
|
| 48 |
+
(?P<post_n2>[0-9]+)?
|
| 49 |
+
)
|
| 50 |
+
)?
|
| 51 |
+
(?P<dev> # dev release
|
| 52 |
+
[-_\.]?
|
| 53 |
+
(?P<dev_l>dev)
|
| 54 |
+
[-_\.]?
|
| 55 |
+
(?P<dev_n>[0-9]+)?
|
| 56 |
+
)?
|
| 57 |
+
)
|
| 58 |
+
(?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
|
| 59 |
+
"""
|
| 60 |
+
|
| 61 |
+
VERSION_REGEX = re.compile(
|
| 62 |
+
r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def pep440(version: str) -> bool:
|
| 67 |
+
"""See :ref:`PyPA's version specification <pypa:version-specifiers>`
|
| 68 |
+
(initially introduced in :pep:`440`).
|
| 69 |
+
"""
|
| 70 |
+
return VERSION_REGEX.match(version) is not None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
# -------------------------------------------------------------------------------------
|
| 74 |
+
# PEP 508
|
| 75 |
+
|
| 76 |
+
PEP508_IDENTIFIER_PATTERN = r"([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])"
|
| 77 |
+
PEP508_IDENTIFIER_REGEX = re.compile(f"^{PEP508_IDENTIFIER_PATTERN}$", re.IGNORECASE)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def pep508_identifier(name: str) -> bool:
|
| 81 |
+
"""See :ref:`PyPA's name specification <pypa:name-format>`
|
| 82 |
+
(initially introduced in :pep:`508#names`).
|
| 83 |
+
"""
|
| 84 |
+
return PEP508_IDENTIFIER_REGEX.match(name) is not None
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
try:
|
| 88 |
+
try:
|
| 89 |
+
from packaging import requirements as _req
|
| 90 |
+
except ImportError: # pragma: no cover
|
| 91 |
+
# let's try setuptools vendored version
|
| 92 |
+
from setuptools._vendor.packaging import ( # type: ignore[no-redef]
|
| 93 |
+
requirements as _req,
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
def pep508(value: str) -> bool:
|
| 97 |
+
"""See :ref:`PyPA's dependency specifiers <pypa:dependency-specifiers>`
|
| 98 |
+
(initially introduced in :pep:`508`).
|
| 99 |
+
"""
|
| 100 |
+
try:
|
| 101 |
+
_req.Requirement(value)
|
| 102 |
+
except _req.InvalidRequirement:
|
| 103 |
+
return False
|
| 104 |
+
return True
|
| 105 |
+
|
| 106 |
+
except ImportError: # pragma: no cover
|
| 107 |
+
_logger.warning(
|
| 108 |
+
"Could not find an installation of `packaging`. Requirements, dependencies and "
|
| 109 |
+
"versions might not be validated. "
|
| 110 |
+
"To enforce validation, please install `packaging`."
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
def pep508(value: str) -> bool: # noqa: ARG001
|
| 114 |
+
return True
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def pep508_versionspec(value: str) -> bool:
|
| 118 |
+
"""Expression that can be used to specify/lock versions (including ranges)
|
| 119 |
+
See ``versionspec`` in :ref:`PyPA's dependency specifiers
|
| 120 |
+
<pypa:dependency-specifiers>` (initially introduced in :pep:`508`).
|
| 121 |
+
"""
|
| 122 |
+
if any(c in value for c in (";", "]", "@")):
|
| 123 |
+
# In PEP 508:
|
| 124 |
+
# conditional markers, extras and URL specs are not included in the
|
| 125 |
+
# versionspec
|
| 126 |
+
return False
|
| 127 |
+
# Let's pretend we have a dependency called `requirement` with the given
|
| 128 |
+
# version spec, then we can reuse the pep508 function for validation:
|
| 129 |
+
return pep508(f"requirement{value}")
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
# -------------------------------------------------------------------------------------
|
| 133 |
+
# PEP 517
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def pep517_backend_reference(value: str) -> bool:
|
| 137 |
+
"""See PyPA's specification for defining build-backend references
|
| 138 |
+
introduced in :pep:`517#source-trees`.
|
| 139 |
+
|
| 140 |
+
This is similar to an entry-point reference (e.g., ``package.module:object``).
|
| 141 |
+
"""
|
| 142 |
+
module, _, obj = value.partition(":")
|
| 143 |
+
identifiers = (i.strip() for i in _chain(module.split("."), obj.split(".")))
|
| 144 |
+
return all(python_identifier(i) for i in identifiers if i)
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# -------------------------------------------------------------------------------------
|
| 148 |
+
# Classifiers - PEP 301
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _download_classifiers() -> str:
|
| 152 |
+
import ssl
|
| 153 |
+
from email.message import Message
|
| 154 |
+
from urllib.request import urlopen
|
| 155 |
+
|
| 156 |
+
url = "https://pypi.org/pypi?:action=list_classifiers"
|
| 157 |
+
context = ssl.create_default_context()
|
| 158 |
+
with urlopen(url, context=context) as response: # noqa: S310 (audit URLs)
|
| 159 |
+
headers = Message()
|
| 160 |
+
headers["content_type"] = response.getheader("content-type", "text/plain")
|
| 161 |
+
return response.read().decode(headers.get_param("charset", "utf-8")) # type: ignore[no-any-return]
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
class _TroveClassifier:
|
| 165 |
+
"""The ``trove_classifiers`` package is the official way of validating classifiers,
|
| 166 |
+
however this package might not be always available.
|
| 167 |
+
As a workaround we can still download a list from PyPI.
|
| 168 |
+
We also don't want to be over strict about it, so simply skipping silently is an
|
| 169 |
+
option (classifiers will be validated anyway during the upload to PyPI).
|
| 170 |
+
"""
|
| 171 |
+
|
| 172 |
+
downloaded: None | Literal[False] | set[str]
|
| 173 |
+
"""
|
| 174 |
+
None => not cached yet
|
| 175 |
+
False => unavailable
|
| 176 |
+
set => cached values
|
| 177 |
+
"""
|
| 178 |
+
|
| 179 |
+
def __init__(self) -> None:
|
| 180 |
+
self.downloaded = None
|
| 181 |
+
self._skip_download = False
|
| 182 |
+
self.__name__ = "trove_classifier" # Emulate a public function
|
| 183 |
+
|
| 184 |
+
def _disable_download(self) -> None:
|
| 185 |
+
# This is a private API. Only setuptools has the consent of using it.
|
| 186 |
+
self._skip_download = True
|
| 187 |
+
|
| 188 |
+
def __call__(self, value: str) -> bool:
|
| 189 |
+
if self.downloaded is False or self._skip_download is True:
|
| 190 |
+
return True
|
| 191 |
+
|
| 192 |
+
if os.getenv("NO_NETWORK") or os.getenv("VALIDATE_PYPROJECT_NO_NETWORK"):
|
| 193 |
+
self.downloaded = False
|
| 194 |
+
msg = (
|
| 195 |
+
"Install ``trove-classifiers`` to ensure proper validation. "
|
| 196 |
+
"Skipping download of classifiers list from PyPI (NO_NETWORK)."
|
| 197 |
+
)
|
| 198 |
+
_logger.debug(msg)
|
| 199 |
+
return True
|
| 200 |
+
|
| 201 |
+
if self.downloaded is None:
|
| 202 |
+
msg = (
|
| 203 |
+
"Install ``trove-classifiers`` to ensure proper validation. "
|
| 204 |
+
"Meanwhile a list of classifiers will be downloaded from PyPI."
|
| 205 |
+
)
|
| 206 |
+
_logger.debug(msg)
|
| 207 |
+
try:
|
| 208 |
+
self.downloaded = set(_download_classifiers().splitlines())
|
| 209 |
+
except Exception: # noqa: BLE001
|
| 210 |
+
self.downloaded = False
|
| 211 |
+
_logger.debug("Problem with download, skipping validation")
|
| 212 |
+
return True
|
| 213 |
+
|
| 214 |
+
return value in self.downloaded or value.lower().startswith("private ::")
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
try:
|
| 218 |
+
from trove_classifiers import classifiers as _trove_classifiers
|
| 219 |
+
|
| 220 |
+
def trove_classifier(value: str) -> bool:
|
| 221 |
+
"""See https://pypi.org/classifiers/"""
|
| 222 |
+
return value in _trove_classifiers or value.lower().startswith("private ::")
|
| 223 |
+
|
| 224 |
+
except ImportError: # pragma: no cover
|
| 225 |
+
trove_classifier = _TroveClassifier()
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
# -------------------------------------------------------------------------------------
|
| 229 |
+
# Stub packages - PEP 561
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def pep561_stub_name(value: str) -> bool:
|
| 233 |
+
"""Name of a directory containing type stubs.
|
| 234 |
+
It must follow the name scheme ``<package>-stubs`` as defined in
|
| 235 |
+
:pep:`561#stub-only-packages`.
|
| 236 |
+
"""
|
| 237 |
+
top, *children = value.split(".")
|
| 238 |
+
if not top.endswith("-stubs"):
|
| 239 |
+
return False
|
| 240 |
+
return python_module_name(".".join([top[: -len("-stubs")], *children]))
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
# -------------------------------------------------------------------------------------
|
| 244 |
+
# Non-PEP related
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def url(value: str) -> bool:
|
| 248 |
+
"""Valid URL (validation uses :obj:`urllib.parse`).
|
| 249 |
+
For maximum compatibility please make sure to include a ``scheme`` prefix
|
| 250 |
+
in your URL (e.g. ``http://``).
|
| 251 |
+
"""
|
| 252 |
+
from urllib.parse import urlparse
|
| 253 |
+
|
| 254 |
+
try:
|
| 255 |
+
parts = urlparse(value)
|
| 256 |
+
if not parts.scheme:
|
| 257 |
+
_logger.warning(
|
| 258 |
+
"For maximum compatibility please make sure to include a "
|
| 259 |
+
"`scheme` prefix in your URL (e.g. 'http://'). "
|
| 260 |
+
f"Given value: {value}"
|
| 261 |
+
)
|
| 262 |
+
if not (value.startswith(("/", "\\")) or "@" in value):
|
| 263 |
+
parts = urlparse(f"http://{value}")
|
| 264 |
+
|
| 265 |
+
return bool(parts.scheme and parts.netloc)
|
| 266 |
+
except Exception: # noqa: BLE001
|
| 267 |
+
return False
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
# https://packaging.python.org/specifications/entry-points/
|
| 271 |
+
ENTRYPOINT_PATTERN = r"[^\[\s=]([^=]*[^\s=])?"
|
| 272 |
+
ENTRYPOINT_REGEX = re.compile(f"^{ENTRYPOINT_PATTERN}$", re.IGNORECASE)
|
| 273 |
+
RECOMMEDED_ENTRYPOINT_PATTERN = r"[\w.-]+"
|
| 274 |
+
RECOMMEDED_ENTRYPOINT_REGEX = re.compile(
|
| 275 |
+
f"^{RECOMMEDED_ENTRYPOINT_PATTERN}$", re.IGNORECASE
|
| 276 |
+
)
|
| 277 |
+
ENTRYPOINT_GROUP_PATTERN = r"\w+(\.\w+)*"
|
| 278 |
+
ENTRYPOINT_GROUP_REGEX = re.compile(f"^{ENTRYPOINT_GROUP_PATTERN}$", re.IGNORECASE)
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def python_identifier(value: str) -> bool:
|
| 282 |
+
"""Can be used as identifier in Python.
|
| 283 |
+
(Validation uses :obj:`str.isidentifier`).
|
| 284 |
+
"""
|
| 285 |
+
return value.isidentifier()
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
def python_qualified_identifier(value: str) -> bool:
|
| 289 |
+
"""
|
| 290 |
+
Python "dotted identifier", i.e. a sequence of :obj:`python_identifier`
|
| 291 |
+
concatenated with ``"."`` (e.g.: ``package.module.submodule``).
|
| 292 |
+
"""
|
| 293 |
+
if value.startswith(".") or value.endswith("."):
|
| 294 |
+
return False
|
| 295 |
+
return all(python_identifier(m) for m in value.split("."))
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def python_module_name(value: str) -> bool:
|
| 299 |
+
"""Module name that can be used in an ``import``-statement in Python.
|
| 300 |
+
See :obj:`python_qualified_identifier`.
|
| 301 |
+
"""
|
| 302 |
+
return python_qualified_identifier(value)
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
def python_module_name_relaxed(value: str) -> bool:
|
| 306 |
+
"""Similar to :obj:`python_module_name`, but relaxed to also accept
|
| 307 |
+
dash characters (``-``) and cover special cases like ``pip-run``.
|
| 308 |
+
|
| 309 |
+
It is recommended, however, that beginners avoid dash characters,
|
| 310 |
+
as they require advanced knowledge about Python internals.
|
| 311 |
+
|
| 312 |
+
The following are disallowed:
|
| 313 |
+
|
| 314 |
+
* names starting/ending in dashes,
|
| 315 |
+
* names ending in ``-stubs`` (potentially collide with :obj:`pep561_stub_name`).
|
| 316 |
+
"""
|
| 317 |
+
if value.startswith("-") or value.endswith("-"):
|
| 318 |
+
return False
|
| 319 |
+
if value.endswith("-stubs"):
|
| 320 |
+
return False # Avoid collision with PEP 561
|
| 321 |
+
return python_module_name(value.replace("-", "_"))
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
def python_entrypoint_group(value: str) -> bool:
|
| 325 |
+
"""See ``Data model > group`` in the :ref:`PyPA's entry-points specification
|
| 326 |
+
<pypa:entry-points>`.
|
| 327 |
+
"""
|
| 328 |
+
return ENTRYPOINT_GROUP_REGEX.match(value) is not None
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
def python_entrypoint_name(value: str) -> bool:
|
| 332 |
+
"""See ``Data model > name`` in the :ref:`PyPA's entry-points specification
|
| 333 |
+
<pypa:entry-points>`.
|
| 334 |
+
"""
|
| 335 |
+
if not ENTRYPOINT_REGEX.match(value):
|
| 336 |
+
return False
|
| 337 |
+
if not RECOMMEDED_ENTRYPOINT_REGEX.match(value):
|
| 338 |
+
msg = f"Entry point `{value}` does not follow recommended pattern: "
|
| 339 |
+
msg += RECOMMEDED_ENTRYPOINT_PATTERN
|
| 340 |
+
_logger.warning(msg)
|
| 341 |
+
return True
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def python_entrypoint_reference(value: str) -> bool:
|
| 345 |
+
"""Reference to a Python object using in the format::
|
| 346 |
+
|
| 347 |
+
importable.module:object.attr
|
| 348 |
+
|
| 349 |
+
See ``Data model >object reference`` in the :ref:`PyPA's entry-points specification
|
| 350 |
+
<pypa:entry-points>`.
|
| 351 |
+
"""
|
| 352 |
+
module, _, rest = value.partition(":")
|
| 353 |
+
if "[" in rest:
|
| 354 |
+
obj, _, extras_ = rest.partition("[")
|
| 355 |
+
if extras_.strip()[-1] != "]":
|
| 356 |
+
return False
|
| 357 |
+
extras = (x.strip() for x in extras_.strip(string.whitespace + "[]").split(","))
|
| 358 |
+
if not all(pep508_identifier(e) for e in extras):
|
| 359 |
+
return False
|
| 360 |
+
_logger.warning(f"`{value}` - using extras for entry points is not recommended")
|
| 361 |
+
else:
|
| 362 |
+
obj = rest
|
| 363 |
+
|
| 364 |
+
module_parts = module.split(".")
|
| 365 |
+
identifiers = _chain(module_parts, obj.split(".")) if rest else iter(module_parts)
|
| 366 |
+
return all(python_identifier(i.strip()) for i in identifiers)
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
def uint8(value: builtins.int) -> bool:
|
| 370 |
+
r"""Unsigned 8-bit integer (:math:`0 \leq x < 2^8`)"""
|
| 371 |
+
return 0 <= value < 2**8
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def uint16(value: builtins.int) -> bool:
|
| 375 |
+
r"""Unsigned 16-bit integer (:math:`0 \leq x < 2^{16}`)"""
|
| 376 |
+
return 0 <= value < 2**16
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
def uint32(value: builtins.int) -> bool:
|
| 380 |
+
r"""Unsigned 32-bit integer (:math:`0 \leq x < 2^{32}`)"""
|
| 381 |
+
return 0 <= value < 2**32
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def uint64(value: builtins.int) -> bool:
|
| 385 |
+
r"""Unsigned 64-bit integer (:math:`0 \leq x < 2^{64}`)"""
|
| 386 |
+
return 0 <= value < 2**64
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
def uint(value: builtins.int) -> bool:
|
| 390 |
+
r"""Signed 64-bit integer (:math:`0 \leq x < 2^{64}`)"""
|
| 391 |
+
return 0 <= value < 2**64
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
def int8(value: builtins.int) -> bool:
|
| 395 |
+
r"""Signed 8-bit integer (:math:`-2^{7} \leq x < 2^{7}`)"""
|
| 396 |
+
return -(2**7) <= value < 2**7
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
def int16(value: builtins.int) -> bool:
|
| 400 |
+
r"""Signed 16-bit integer (:math:`-2^{15} \leq x < 2^{15}`)"""
|
| 401 |
+
return -(2**15) <= value < 2**15
|
| 402 |
+
|
| 403 |
+
|
| 404 |
+
def int32(value: builtins.int) -> bool:
|
| 405 |
+
r"""Signed 32-bit integer (:math:`-2^{31} \leq x < 2^{31}`)"""
|
| 406 |
+
return -(2**31) <= value < 2**31
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
def int64(value: builtins.int) -> bool:
|
| 410 |
+
r"""Signed 64-bit integer (:math:`-2^{63} \leq x < 2^{63}`)"""
|
| 411 |
+
return -(2**63) <= value < 2**63
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
def int(value: builtins.int) -> bool:
|
| 415 |
+
r"""Signed 64-bit integer (:math:`-2^{63} \leq x < 2^{63}`)"""
|
| 416 |
+
return -(2**63) <= value < 2**63
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
try:
|
| 420 |
+
from packaging import licenses as _licenses
|
| 421 |
+
|
| 422 |
+
def SPDX(value: str) -> bool:
|
| 423 |
+
"""See :ref:`PyPA's License-Expression specification
|
| 424 |
+
<pypa:core-metadata-license-expression>` (added in :pep:`639`).
|
| 425 |
+
"""
|
| 426 |
+
try:
|
| 427 |
+
_licenses.canonicalize_license_expression(value)
|
| 428 |
+
except _licenses.InvalidLicenseExpression:
|
| 429 |
+
return False
|
| 430 |
+
return True
|
| 431 |
+
|
| 432 |
+
except ImportError: # pragma: no cover
|
| 433 |
+
_logger.warning(
|
| 434 |
+
"Could not find an up-to-date installation of `packaging`. "
|
| 435 |
+
"License expressions might not be validated. "
|
| 436 |
+
"To enforce validation, please install `packaging>=24.2`."
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
def SPDX(value: str) -> bool: # noqa: ARG001
|
| 440 |
+
return True
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
VALID_IMPORT_NAME = re.compile(
|
| 444 |
+
r"""
|
| 445 |
+
^ # start of string
|
| 446 |
+
[A-Za-z_][A-Za-z_0-9]+ # a valid Python identifier
|
| 447 |
+
(?:\.[A-Za-z_][A-Za-z_0-9]*)* # optionally followed by .identifier's
|
| 448 |
+
(?:\s*;\s*private)? # optionally followed by ; private
|
| 449 |
+
$ # end of string
|
| 450 |
+
""",
|
| 451 |
+
re.VERBOSE,
|
| 452 |
+
)
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
def import_name(value: str) -> bool:
|
| 456 |
+
"""This is a valid import name. It has to be series of python identifiers
|
| 457 |
+
(not keywords), separated by dots, optionally followed by a semicolon and
|
| 458 |
+
the keyword "private".
|
| 459 |
+
"""
|
| 460 |
+
if VALID_IMPORT_NAME.match(value) is None:
|
| 461 |
+
return False
|
| 462 |
+
|
| 463 |
+
idents, _, _ = value.partition(";")
|
| 464 |
+
return all(not keyword.iskeyword(ident) for ident in idents.rstrip().split("."))
|
python/Lib/site-packages/setuptools/tests/__pycache__/__init__.cpython-313.pyc
ADDED
|
Binary file (673 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_build_clib.cpython-313.pyc
ADDED
|
Binary file (4.23 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_build_ext.cpython-313.pyc
ADDED
|
Binary file (13.4 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_build_meta.cpython-313.pyc
ADDED
|
Binary file (43.9 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_build_py.cpython-313.pyc
ADDED
|
Binary file (17.1 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_config_discovery.cpython-313.pyc
ADDED
|
Binary file (30.7 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_core_metadata.cpython-313.pyc
ADDED
|
Binary file (20.1 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_depends.cpython-313.pyc
ADDED
|
Binary file (956 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_develop.cpython-313.pyc
ADDED
|
Binary file (5.54 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_dist.cpython-313.pyc
ADDED
|
Binary file (11 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_dist_info.cpython-313.pyc
ADDED
|
Binary file (7.85 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_distutils_adoption.cpython-313.pyc
ADDED
|
Binary file (8.03 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_editable_install.cpython-313.pyc
ADDED
|
Binary file (57.3 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_egg_info.cpython-313.pyc
ADDED
|
Binary file (48.2 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_extern.cpython-313.pyc
ADDED
|
Binary file (837 Bytes). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_find_packages.cpython-313.pyc
ADDED
|
Binary file (12.1 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_find_py_modules.cpython-313.pyc
ADDED
|
Binary file (3.86 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_glob.cpython-313.pyc
ADDED
|
Binary file (1.25 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_install_scripts.cpython-313.pyc
ADDED
|
Binary file (6.12 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_logging.cpython-313.pyc
ADDED
|
Binary file (3.25 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_manifest.cpython-313.pyc
ADDED
|
Binary file (27 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_namespaces.cpython-313.pyc
ADDED
|
Binary file (3.19 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_scripts.cpython-313.pyc
ADDED
|
Binary file (1.09 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_sdist.cpython-313.pyc
ADDED
|
Binary file (46.3 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_setopt.cpython-313.pyc
ADDED
|
Binary file (2.87 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_setuptools.cpython-313.pyc
ADDED
|
Binary file (18.6 kB). View file
|
|
|
python/Lib/site-packages/setuptools/tests/__pycache__/test_shutil_wrapper.cpython-313.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|