Skip to main content

The traits-stubs package contains external type annotations for the Traits package. These annotations can be used with static type checkers like mypy to type-check your Traits-using Python code.

Installation

  • To install from PyPI, simply use pip install traits-stubs.

  • To install from source, run pip install . from this directory.

Usage

You’ll usually want to install mypy (or another type checker) into your Python environment alongside these stubs. You can then use mypy from the command line to check a file or directory, for example with:

mypy <somefile.py>

Alternatively, some IDEs (including VS Code and PyCharm) can be configured to perform type checking as you edit.

Development

To test traits stubs locally:

  • Create a fresh venv and activate it, for example with:

    $ python -m venv --clear ~/.venvs/traits-stubs && source ~/.venvs/traits-stubs/bin/activate
  • Make sure all build-related packages are up to date

    $ python -m pip install –upgrade pip setuptools wheel

  • Install the Traits library into the environment (non-editable install)

    $ python -m pip install .

  • Install traits stubs in editable mode (from the repo, not from PyPI).

    $ python -m pip install -e traits-stubs/

  • Install mypy (or your favourite type checker)

    $ python -m pip install mypy

  • From the traits-stubs directory, run mypy on individual files in traits_stubs_tests/examples with e.g.,

    $ python -m mypy traits_stubs_tests/examples/completeness.py

  • From the traits-stubs directory, run the test suite with:

    $ python -m unittest discover -v traits_stubs_tests

Note: it’s easy to get confusing results if you accidentally use the wrong version of mypy. To avoid that, you can make sure that you don’t have mypy installed globally, and/or always invoke mypy using python -m mypy from within the environment.

Note: the unittest run can give the wrong result in the presence of a stale .mypy_cache. If you’re getting a pass where you expect to get a failure (or vice versa), try deleting the local cache and trying again.

Dependencies

This package depends on Traits.

Metadata

Release files for traits-stubs 6.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traits-stubs 6.4.0
File Size Uploaded
traits-stubs-6.4.0.tar.gz 20.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for traits-stubs 6.4.0
File Interpreter ABI Platform
traits_stubs-6.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.7 kB

Release files / traits-stubs-6.4.0.tar.gz

Download URL traits-stubs-6.4.0.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a0b17cc6c3c93ef0e868a93283cd1af88ff6cba04a0e70e84147aa73b7bca43d
BLAKE2b-256 checksum
How to use checksums
929695f2b69428c0b88aad1f201ff29b486947c417beb25ac494e0d977d09b4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / traits_stubs-6.4.0-py3-none-any.whl

Download URL traits_stubs-6.4.0-py3-none-any.whl
Size 45.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a97c4503cb9512a973896a7ed7757f71eed5dd2f6b3de0d4113c886a74d9da0d
BLAKE2b-256 checksum
How to use checksums
2f879a1769591c4f5254553ece9ed81c379885fdeefb07e6ea6598ece33eda34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

6.4.0 This release

2 release files

6.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page