This commit is contained in:
Waylon Walker 2022-03-31 20:20:07 -05:00
commit 38355d2442
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
9083 changed files with 1225834 additions and 0 deletions

View file

@ -0,0 +1,62 @@
# Licensing terms
Traitlets is adapted from enthought.traits, Copyright (c) Enthought, Inc.,
under the terms of the Modified BSD License.
This project is licensed under the terms of the Modified BSD License
(also known as New or Revised or 3-Clause BSD), as follows:
- Copyright (c) 2001-, IPython Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
Neither the name of the IPython Development Team nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## About the IPython Development Team
The IPython Development Team is the set of all contributors to the IPython project.
This includes all of the IPython subprojects.
The core team that coordinates development on GitHub can be found here:
https://github.com/jupyter/.
## Our Copyright Policy
IPython uses a shared copyright model. Each contributor maintains copyright
over their contributions to IPython. But, it is important to note that these
contributions are typically only changes to the repositories. Thus, the IPython
source code, in its entirety is not the copyright of any single person or
institution. Instead, it is the collective copyright of the entire IPython
Development Team. If individual contributors want to maintain a record of what
changes/contributions they have specific copyright on, they should indicate
their copyright in the commit message of the change, when they commit the
change to one of the IPython repositories.
With this in mind, the following banner should be used in any source code file
to indicate the copyright and license terms:
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

View file

@ -0,0 +1,195 @@
Metadata-Version: 2.1
Name: traitlets
Version: 5.1.1
Summary: Traitlets Python configuration system
Home-page: https://github.com/ipython/traitlets
Author: IPython Development Team
Author-email: ipython-dev@python.org
License: BSD
Project-URL: Documentation, https://traitlets.readthedocs.io/
Project-URL: Funding, https://numfocus.org/
Project-URL: Source, https://github.com/ipython/traitlets
Project-URL: Tracker, https://github.com/ipython/traitlets/issues
Keywords: Interactive,Interpreter,Shell,Web
Platform: Linux
Platform: Mac OS X
Platform: Windows
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: COPYING.md
Provides-Extra: test
Requires-Dist: pytest ; extra == 'test'
# Traitlets
[![Tests](https://github.com/ipython/traitlets/actions/workflows/tests.yml/badge.svg)](https://github.com/ipython/traitlets/actions/workflows/tests.yml)
[![Test downstream projects](https://github.com/ipython/traitlets/actions/workflows/downstream.yml/badge.svg)](https://github.com/ipython/traitlets/actions/workflows/downstream.yml)
[![Documentation Status](https://readthedocs.org/projects/traitlets/badge/?version=latest)](https://traitlets.readthedocs.io/en/latest/?badge=latest)
| | |
|---------------|----------------------------------------|
| **home** | https://github.com/ipython/traitlets |
| **pypi-repo** | https://pypi.org/project/traitlets/ |
| **docs** | https://traitlets.readthedocs.io/ |
| **license** | Modified BSD License |
Traitlets is a pure Python library enabling:
- the enforcement of strong typing for attributes of Python objects
(typed attributes are called *"traits"*);
- dynamically calculated default values;
- automatic validation and coercion of trait attributes when attempting a
change;
- registering for receiving notifications when trait values change;
- reading configuring values from files or from command line
arguments - a distinct layer on top of traitlets, so you may use
traitlets without the configuration machinery.
Its implementation relies on the [descriptor](https://docs.python.org/howto/descriptor.html)
pattern, and it is a lightweight pure-python alternative of the
[*traits* library](https://docs.enthought.com/traits/).
Traitlets powers the configuration system of IPython and Jupyter
and the declarative API of IPython interactive widgets.
## Installation
For a local installation, make sure you have
[pip installed](https://pip.pypa.io/en/stable/installing/) and run:
```bash
pip install traitlets
```
For a **development installation**, clone this repository, change into the
`traitlets` root directory, and run pip:
```bash
git clone https://github.com/ipython/traitlets.git
cd traitlets
pip install -e .
```
## Running the tests
```bash
pip install "traitlets[test]"
py.test traitlets
```
## Usage
Any class with trait attributes must inherit from `HasTraits`.
For the list of available trait types and their properties, see the
[Trait Types](https://traitlets.readthedocs.io/en/latest/trait_types.html)
section of the documentation.
### Dynamic default values
To calculate a default value dynamically, decorate a method of your class with
`@default({traitname})`. This method will be called on the instance, and
should return the default value. In this example, the `_username_default`
method is decorated with `@default('username')`:
```Python
import getpass
from traitlets import HasTraits, Unicode, default
class Identity(HasTraits):
username = Unicode()
@default('username')
def _username_default(self):
return getpass.getuser()
```
### Callbacks when a trait attribute changes
When a trait changes, an application can follow this trait change with
additional actions.
To do something when a trait attribute is changed, decorate a method with
[`traitlets.observe()`](https://traitlets.readthedocs.io/en/latest/api.html?highlight=observe#traitlets.observe).
The method will be called with a single argument, a dictionary which contains
an owner, new value, old value, name of the changed trait, and the event type.
In this example, the `_num_changed` method is decorated with ``@observe(`num`)``:
```Python
from traitlets import HasTraits, Integer, observe
class TraitletsExample(HasTraits):
num = Integer(5, help="a number").tag(config=True)
@observe('num')
def _num_changed(self, change):
print("{name} changed from {old} to {new}".format(**change))
```
and is passed the following dictionary when called:
```Python
{
'owner': object, # The HasTraits instance
'new': 6, # The new value
'old': 5, # The old value
'name': "foo", # The name of the changed trait
'type': 'change', # The event type of the notification, usually 'change'
}
```
### Validation and coercion
Each trait type (`Int`, `Unicode`, `Dict` etc.) may have its own validation or
coercion logic. In addition, we can register custom cross-validators
that may depend on the state of other attributes. For example:
```Python
from traitlets import HasTraits, TraitError, Int, Bool, validate
class Parity(HasTraits):
value = Int()
parity = Int()
@validate('value')
def _valid_value(self, proposal):
if proposal['value'] % 2 != self.parity:
raise TraitError('value and parity should be consistent')
return proposal['value']
@validate('parity')
def _valid_parity(self, proposal):
parity = proposal['value']
if parity not in [0, 1]:
raise TraitError('parity should be 0 or 1')
if self.value % 2 != parity:
raise TraitError('value and parity should be consistent')
return proposal['value']
parity_check = Parity(value=2)
# Changing required parity and value together while holding cross validation
with parity_check.hold_trait_notifications():
parity_check.value = 1
parity_check.parity = 1
```
However, we **recommend** that custom cross-validators don't modify the state
of the HasTraits instance.
### Release build:
Releases should be automatically build and pushed to Pypi when a tag is marked and pushed to GitHub.
```bash
$ pip install build
$ python -m build .
```

View file

@ -0,0 +1,68 @@
traitlets-5.1.1.dist-info/COPYING.md,sha256=cciRKQObhwzJIwlGbE--jyhagvoOo28OhA-oOXnL4x8,2957
traitlets-5.1.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
traitlets-5.1.1.dist-info/METADATA,sha256=jHZ6G1HtlrUMSPhbqeujCjm1qSDMrTkLefIpJLEG9As,6537
traitlets-5.1.1.dist-info/RECORD,,
traitlets-5.1.1.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
traitlets-5.1.1.dist-info/top_level.txt,sha256=EtJSeHWD2tDo4fwq8c2hXVryySaLl6HicKeISu9QIJU,10
traitlets/__init__.py,sha256=H_B4YjqLCgminvUUUgEO9o7fKG4N66qv5z1RBPNPmr4,639
traitlets/__pycache__/__init__.cpython-38.pyc,,
traitlets/__pycache__/_version.cpython-38.pyc,,
traitlets/__pycache__/log.cpython-38.pyc,,
traitlets/__pycache__/traitlets.cpython-38.pyc,,
traitlets/_version.py,sha256=6a42s5yUt6du2XjosqdhrNLKtzsNywO_fYf3yLe734I,372
traitlets/config/__init__.py,sha256=HdKqizrHk_A1Jf3qr5pWH-pEM2wyNSZq-cN1a40AePQ,203
traitlets/config/__pycache__/__init__.cpython-38.pyc,,
traitlets/config/__pycache__/application.cpython-38.pyc,,
traitlets/config/__pycache__/configurable.cpython-38.pyc,,
traitlets/config/__pycache__/loader.cpython-38.pyc,,
traitlets/config/__pycache__/manager.cpython-38.pyc,,
traitlets/config/__pycache__/sphinxdoc.cpython-38.pyc,,
traitlets/config/application.py,sha256=bpBMayU1EP5BgDUQYEOfz_yBqU9h2_iY1Kgf32YWh8Q,33485
traitlets/config/configurable.py,sha256=HiGslG0IW12daxVYjdt-SUNM21S9oQjgtgpTsIgAvhA,20846
traitlets/config/loader.py,sha256=OkvUZtKEWY0dYJ_L1n0a1_xNgz0hynNBuDl2En-w2jE,35607
traitlets/config/manager.py,sha256=gFNnvkw4nfRhcJ8ACQ42Tc1TCUkxHfsSkBwfUq7j2ys,2333
traitlets/config/sphinxdoc.py,sha256=sXxGDUDwwzDsRDSs02tXtOxJzTolMnERXkbPrvP6aB8,5017
traitlets/config/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
traitlets/config/tests/__pycache__/__init__.cpython-38.pyc,,
traitlets/config/tests/__pycache__/test_application.cpython-38.pyc,,
traitlets/config/tests/__pycache__/test_configurable.cpython-38.pyc,,
traitlets/config/tests/__pycache__/test_loader.cpython-38.pyc,,
traitlets/config/tests/test_application.py,sha256=j868X_6r1ofIKhOQUvvhnPrqjt15rJdmrnaxpSp4gOQ,26301
traitlets/config/tests/test_configurable.py,sha256=c2F0roQFfE-3CCQCiVIkB_TYUQiEoNCzT1n2obX38B8,22466
traitlets/config/tests/test_loader.py,sha256=Gj5e-sGtzSoFIXkRjgdpL60KkI2AXtwHbs5fyGlLY3U,22435
traitlets/log.py,sha256=MimotlTTF1h5NVHfow9nezn6TeGlogwl84EIk8ZOCts,779
traitlets/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
traitlets/tests/__pycache__/__init__.cpython-38.pyc,,
traitlets/tests/__pycache__/_warnings.cpython-38.pyc,,
traitlets/tests/__pycache__/test_traitlets.cpython-38.pyc,,
traitlets/tests/__pycache__/test_traitlets_enum.cpython-38.pyc,,
traitlets/tests/__pycache__/utils.cpython-38.pyc,,
traitlets/tests/_warnings.py,sha256=69MC4Hk_Xo_iQ5EhLdevJAxSfZxIFIS5WlcySM4nhyc,4078
traitlets/tests/test_traitlets.py,sha256=doKTkgxAeLnv_zhjxCkyO3fC4KofyiWhR6sU7YmWNmY,77199
traitlets/tests/test_traitlets_enum.py,sha256=nj1K6-Fz_Pln29gS1QTy1a8dLqAC7Nb0sdBaE-D4mSo,13646
traitlets/tests/utils.py,sha256=V-8Yjv4SHHbW13eEOspF90RdZDqAauH_4fsafkpS5jw,1141
traitlets/traitlets.py,sha256=UhNDrGi2uzxOPku3bIE6O6sFwKAdhmSVQJiUuFLwQoA,114926
traitlets/utils/__init__.py,sha256=1AEcdl4VwZ2kIgj4Rxfd42Zk_sqPVdWOoLVQq8WuIA4,2920
traitlets/utils/__pycache__/__init__.cpython-38.pyc,,
traitlets/utils/__pycache__/bunch.cpython-38.pyc,,
traitlets/utils/__pycache__/decorators.cpython-38.pyc,,
traitlets/utils/__pycache__/descriptions.cpython-38.pyc,,
traitlets/utils/__pycache__/getargspec.cpython-38.pyc,,
traitlets/utils/__pycache__/importstring.cpython-38.pyc,,
traitlets/utils/__pycache__/sentinel.cpython-38.pyc,,
traitlets/utils/__pycache__/text.cpython-38.pyc,,
traitlets/utils/bunch.py,sha256=L56x1dMTw1vsRK3uG5Pb6KyLGqWFZFWl0gBRbaXXF74,652
traitlets/utils/decorators.py,sha256=j7bveZodf0BHxGYHJ6bWphv8l_W6P45Tne_0LhlgtLQ,2889
traitlets/utils/descriptions.py,sha256=DtCzXr9y_Cwopcn5r9I0sHyTKwbzjE5gM2Xb1uUgV5I,5343
traitlets/utils/getargspec.py,sha256=kgLeqW685Sg3ZgxH45oTLnXGXDdvP4AP1qRzXCtzhl8,1610
traitlets/utils/importstring.py,sha256=7_jmHKTPUq2SbIDkjY_oAlrIVOVXgcm8XEBlop7lrnA,1127
traitlets/utils/sentinel.py,sha256=eRXFE4cql0gvmDrfVaFATqc3nBs9MEg4-H2XWNIIsl0,524
traitlets/utils/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
traitlets/utils/tests/__pycache__/__init__.cpython-38.pyc,,
traitlets/utils/tests/__pycache__/test_bunch.cpython-38.pyc,,
traitlets/utils/tests/__pycache__/test_decorators.cpython-38.pyc,,
traitlets/utils/tests/__pycache__/test_importstring.cpython-38.pyc,,
traitlets/utils/tests/test_bunch.py,sha256=6zBI-dKnHKlQ75m-EBYiHczKkz6DEW9N4vkOOL295kA,272
traitlets/utils/tests/test_decorators.py,sha256=nlXv0gjv3FgdazqMqryFvzB3y-zwbXRjdcAmn52AI5c,4788
traitlets/utils/tests/test_importstring.py,sha256=Tv11no57mFzFNrX2mqW0Sh6cccJPYj_HA1U1FIhicRo,861
traitlets/utils/text.py,sha256=FN9VvhwW0_ALL2yxOSYWpsZ3MO9gEPJxPIV01TLGytY,1042

View file

@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.37.0)
Root-Is-Purelib: true
Tag: py3-none-any

View file

@ -0,0 +1 @@
traitlets