Releases: enthought/traits
Traits 7.0.2
This is a bugfix release of the Traits package that fixes an interoperability
issue with Pyface (a regression since Traits 6.4.3).
Fixes
- Make
traits.trait_notifiers.ui_handlerpublic again, since
Pyface relies on importing it directly. (#1827)
Build
- Include Python 3.13 in all test workflows. (#1826)
Traits 7.0.1
This is a bugfix release of the Traits package that adjusts the wheel
building configuration. There are no non-packaging-related changes
in this release.
Changes
- Drop problematic manylinux/aarch64 wheel builds; build separate wheels
for macOS/arm64 and macOS/x86_64. (#1822)
Traits 7.0.0
This is a major release of the Traits package. Some highlights:
- Python versions through Python 3.13 are now supported.
- The Traits package now includes (partial) type hints. (Type hints
were previously distributed in a separatetraits-stubspackage.) - There is some experimental and provisional support for async
observer dispatch. - Many long-deprecated pieces of functionality have finally been removed
from the codebase.
Detailed changes
The following people contributed code changes and reviews for this release:
- Mark Dickinson
- Robert Haschke
- Chengyu Liu
- Frank Longford
- Sai Rahul Poruri
- Matt Smarte
- Corran Webster
Features
- The traits package now ships with stub files directly, instead of requiring
those files to be installed via the separatetraits-stubspackage.
(#1714) - Experimental support for async dispatch has been added. This API should
be considered provisional, and may change in the future. (#1771) - Python versions through 3.13 are now supported. (#1773)
- Event types
TraitChangeEvent,ListChangeEvent,DictChangeEvent
andSetChangeEventfor theeventreceived by observers are now
available intraits.observation.api. This is useful for those wanting to
use the types in type annotations. (#1805)
Changes
- The behaviour of observers using
dispatch="ui"when no GUI system is
present (in particular, if Pyface has not performed toolkit selection)
has changed. Previously, if such an observer was triggered then
it would raise an exception. Now it will raise with a clear error message
if triggered from a thread other than the main thread, and will execute
synchronously if triggered on the main thread. (#1740) AttributeErrors raised bysome_trait_defaultmethods are
no longer swallowed. (#1762)- The
Datetrait type no longer acceptsdatetimeinstances
unlessallow_datetime=Trueis used. (#1736) - The
Date,TimeandDatetimetrait types no longer
accept a value ofNoneunlessallow_none=Trueis used. (#1736) - Calling an interface class no longer performs implicit adaptation.
Adaptation must be performed explicitly, using theadaptfunction.
(#1719)
Removals
- Python versions earlier than 3.8 are no longer supported. (#1773)
- Removed deprecated
rich_compareTrait metadata. (#1698) - Removed deprecated
find_resourceandstore_resourcefunctions. (#1697) - Removed deprecated
TraitList,TraitDictandTraitTupleclasses.
(#1634) - Removed the deprecated ability of
cTrait.default_valueto set the default
value of a trait. It can now only be used for getting, not for setting.
(#1632) - Removed the deprecated
typecodeparameter toArraytrait types.
(#1633) - Removed the deprecated
nose_toolsmodule. (#1636) - Removed the deprecated
Long,CLong,BaseLongandBaseCLong
trait types. UseInt,CInt,BaseIntandBaseCIntinstead.
(#1701) - Removed the deprecated
TraitPrefixListandTraitPrefixMapclasses.
UsePrefixListandPrefixMapinstead. (#1703) - Removed the deprecated
Function,MethodandSymboltrait types.
(#1819) - Removed the deprecated
SingletonHasTraits,SingletonHasStrictTraits
andSingletonHasPrivateTraitsclasses. (#1794) - Removed the deprecated
HasTraits.getandHasTraits.setmethods.
(#1738) - Removed the deprecated
MetaHasTraits.add_listenerand
MetaHasTraits.remove_listenermethods. (#1730) - Removed the deprecated
Color,RGBColorandFonttraits.
Code that needs these trait types should import them from TraitsUI instead.
(#1737) - Removed the deprecated trait type aliases
ListInt,ListFloat,
ListStr,ListUnicode,ListComplex,ListBool,
ListFunction,ListMethod,ListThis,DictStrAny,
DictStrStr,DictStrInt,DictStrFloat,DictStrBool,
DictStrList. (#1723) - Removed the deprecated
clean_filenameandclean_timestamp
utilities. (#1820)
Fixes
- Fixed build error on Python 3.13 triggered by removal of the
PyTRASHCAN_SAFE_BEGINandPyTRASHCAN_SAFE_ENDmacros. (#1767) - Fixed warning messages from use of
PyDict_GetItemin Python >= 3.13.
(#1818) - Fixed a race condition in test of background thread notification. (#1798)
- Fixed missing observer registration when inserting into a nested
list. (#1761) - Fixed a use of the deprecated
datetime.datetime.utcnowmethod. (#1758) - Fixed a use of a deprecated TraitsUI version check. (#1746)
- Fixed various type stubs. (#1718)
Tests
- Reworked
ui_dispatchtests to no longer require Qt. (#1792) - Removed Cython-based tests (after fixing them). (#1793, #1759)
- Fixed two tests that were triggering TraitsUI deprecation warnings. (#1790)
- Remove uses of
UITesterfrom the test suite. (#1788) - Fix a fragile
configure_traitstest that could fail on warnings unrelated
to the test goal. (#1749)
Build and continuous integration
- Added Python 3.11 to the workflow that tests wheels from PyPI. (#1715)
- Added dependabot config to aid keeping GitHub Actions up to date. (#1776)
- Brought various GitHub Actions up to date. (#1814, #1810, #1808,
#1807, #1800, #1799, #1797, #1796, #1780, #1779, #1778, #1777) - Removed uses of the
voxmediaaction for Slack notification. (#1782) - Fix the set of architectures tested in the PyPI workflow. (#1795)
- Removed PySide as a test dependency. (#1791)
- Fixed a couple of compiler warnings related to integer conversions in the
Windows build. (#1774) - Temporarily pinned the Python 3.13 version to avoid an upstream bug with
Python 3.13.0a4. (#1775, #1773) - Updated workflows for Python 3.12 support. (#1757)
- Updated workflows for compatibility with Ubuntu 22.04. (#1727)
- Updated workflows to use Python 3.11 final. (#1725)
- Moved cibuildwheel config to
pyproject.toml. (#1717) - Temporarily pinned
setuptoolsto avoid an incompatibility with EDM
runtimes. (#1722) - The PyPI release workflow has been modernized. (#1716)
Documentation
- Clarify behaviour of observers listening to
attr1:attr2. (#1806) - Fixed Trait documenter tests for Sphinx >= 7.2. (#1755)
- Fixed inconsistent spacing style in docs. (#1728)
Miscellaneous
Traits 6.4.3
This is a bugfix release that fixes test failures with Sphinx 7.2 and later,
and adds support for Python 3.12.
Fixes
Traits 6.4.2
Traits 6.4.1
This is a bugfix release that fixes wheel builds on Python 3.11 and
fixes some distribution and testing issues with typing stubs.
Fixes
* Update `cibuildwheel` to the latest version so that we get wheels for
Python 3.11. (#1711)
* Rename `requires_numpy_testing` decorator to `requires_numpy_typing`,
and have it check for `numpy.typing`, not `numpy.testing`. (#1710)
* Fix missing `numpy_examples` directory in traits-stubs package data.
(#1709)
Traits 6.4.0
Traits 6.4 is a minor feature release of Traits, which focuses mainly on typing
stub and documentation updates.
Migrating from Traits 6.3
Traits 6.4 should be largely backwards compatible with Traits 6.3, but there
are a couple of things to watch out for.
- Reminder: while the
EitherandTraittrait types are not yet formally
deprecated, the intention is to eventually deprecate and remove them.
Projects are encouraged to update their code to useUnioninstead. - Similarly, any uses of the
Unicodetrait type in your project should
be replaced withStr. - Validation of items within a container (e.g.,
foos = List(MyTraitType))
now always matches the validation used for the item trait at top level (e.g.,
foo = MyTraitType). Previously, the validation methods used could differ,
thanks to a bug in the container implementations. For most trait types this
will make no difference, but for theTupletrait type this change has the
consequence that lists will no longer be accepted as valid forTuple
traits inside list items. See issue #1619 and PR #1625 for more information. - Related to the above: a top-level
Tuple()trait declaration currently
accepts Pythonlistobjects, while aTupledeclaration with explicit
item types (for exampleTuple(Int(), Int())) does not. The support for
listobjects in plainTuple()is deprecated, and will be removed in a
future version of Traits. See PR #1627 for more information.
Detailed PR-by-PR changes
The following people contributed code changes for this release:
- Caio Agiani
- Steve Allen
- Mark Dickinson
- Sai Rahul Poruri
- Corran Webster
Features
ETSConfigattributes now support deletion. This makes it easier to make
temporary changes toETSConfigattributes during unit testing. (#1670,
#1686)Complextrait type validation is now more lenient: any type that
implements__complex__will be accepted. (#1594)BaseFloatvalidation is now more lenient, and matchesFloat
validation:BaseFloatnow also accepts objects whose type has an
__index__method. (#1595)
Changes
- An
enumeratealias has been removed fromtraits.trait_base. In the
unlikely event of code that importsenumeratefromtraits.trait_base,
use the built-inenumerateinstead. (#1681) - Fast validation tuples
int_fast_validate,float_fast_validateand
complex_fast_validatehave been removed from thetraits.trait_types
module. (#1601)
Fixes
TraitListObject,TraitDictobject andTraitSetObjectnow use the
validatemethod of the appropriateCTraitinstances to validate
items, keys and values. Previously the handler'svalidatemethod was
used; this gave buggy behaviour in cases where the handler'svalidate
method differed from the actual validation in use. (#1625)- Fix specification of
default_valuethat incorrectly disregarded
default_value_type. (#1631) - Fix incorrect results from
clone_traitsapplied toList,Dict
andSettraits. (#1624) - The
find_resourceandstore_resourcetests are now skipped
if thepkg_resourcesmodule is not present in the environment. (#1679) - An
ETSConfigtest has been renamed so that it's properly picked up
by the test runner. (#1671) - Fix some
ETSConfigtests that assume unittest as the test runner. (#1683) - Rename various test-related classes to avoid pytest trying to harvest test
methods from them. (#1684) - Overriding a default for a
Listor other collection trait in a subclass
now works as expected. Previously, the behaviour was unusably buggy. (#1645)
Deprecations
Tupletraits currently accept Pythonlistobjects in some (but
not all) circumstances. That feature is deprecated, and will be removed
in a future version of Traits. (#1627)
Type stubs
- Add stubs for
Array,ArrayOrNone, andCArray. (#1682) - Fix various stubs for
traits.trait_types; add stubs for
traits.ctraits. (#1661) - Fix that
TraitErrorstubs weren't exposed attraits.apilevel.
(#1658) - Make
IntandFloattype stubs more accurate. (#1656) - Fix incorrect type stubs for the
Dicttrait type. (#1655)
Documentation
- Make
ETSConfigclass documentation visible in the API docs. (#1688) - Add copy buttons to code samples in documentation. (#1651, #1653)
- Document
Date,DatetimeandTimetrait types. (#1641) - Fix some missing mentions of
Setin notification docs. (#1618) - Document the
'some_trait.-'pattern foron_trait_change. (#1592) - Document that
Eithershould not be used in new code. (#1699) - Document that
TraitPrefixMapandTraitPrefixListare deprecated.
(#1702) - Document that the Trait factory function should not be used in new code.
(#1700) - Miscellaneous minor fixes. (#1583, #1611, #1652, #1680)
Build and continuous integration
- Don't collect traits-stubs tests under pytest. As a result of this
and other fixes, the test suite now passes under pytest. (#1690) - Update
etstool.pyfor Python 3.8 support. Python 3.8 is now the
default Python version for builds. (#1694) - Use PySide6 for Python >= 3.8 instead of PySide2 in CI testing. (#1685)
- Add
pyproject.tomlfiles for both Traits and traits-stubs. (#1689, #1676) - Add Python 3.11 to some workflow runs. (#1600, #1660, #1674)
- Add Python 3.10 to install-from-PyPI workflow. (#1576)
- Allow running the main test workflow manually. (#1607)
- Switch Slack channel used to report GitHub Actions failures. (#1650)
- Exclude
builddirectory in flake8 configuration. (#1635) - Re-include NumPy as a test dependency on Python 3.10. (#1593)
Maintenance and refactoring
Traits 6.3.2
Traits 6.3.2 is a bugfix release, fixing an issue with duplicate
notifications from Property traits using the observe framework.
Fixes
- Fix that
Propertytraits usingobservemetadata could be fired
twice in subclasses. (#1587)
Traits 6.3.1
Traits 6.3.1 is a bugfix release, fixing an incompatibility between Traits 6.3.0 and Mayavi <= 4.7.3.
Fixes
- Make
PrefixMap._mapavailable again, for compatibility with Mayavi.
(#1578)
Traits 6.3.0
Traits 6.3 is the latest feature release in the Traits 6 series, with several
improvements and fixes over Traits 6.2.
Highlights of this release
- There have been various minor performance improvements to the core
on_trait_changeandobservemachinery. These may improve
startup time for some Traits-using applications. - The
observemini-language now has in-language support for listening
to all traits, using the*character. - Support for Python 3.10 has been added.
Migration guide
Traits 6.3 is intended to be fully backwards compatible with Traits 6.2, and
most projects should have no difficulties upgrading. However, you may see
some new deprecation warnings for existing code, warning about behaviour
that will be changed in Traits 7.0. There are two particular sets of changes
to look out for:
-
Starting with Traits 7.0, the
Anytrait type will treat a default
value of typelistordictdifferently. Currently, instances of
listanddictare special-cased, and a per-instance copy of the
default is provided to eachHasTraitsinstance. In Traits 7.0, this
special-casing will be removed, and the default value will be shared between
all instances. For the 6.3 release of Traits, a deprecation warning is issued
whenever a trait definition of the formAny([1, 2, 3])orAny({})
is encountered. Users can retain the existing behaviour and suppress the
warning by changing their code to use the newfactoryargument to the
Anytrait type, for example replacing a trait declarationfoo = Any({})withfoo = Any(factory=dict), and a trait declarationfoo = Any([1, 2, 3])withfoo = Any(factory=list, args=([1, 2, 3],)). -
Starting with Traits 7.0, the
Datetrait type will no longer accept
datetimeinstances by default. Traits 6.3 will issue a deprecation
warning whenever adatetimeinstance is assigned as a value for
aDatetrait. The existing behaviour can be preserved and the warning
silenced by usingDate(allow_datetime=True); alternatively, you can
useDate(allow_datetime=False)to adopt the Traits 7.0 behaviour
right now.
Detailed PR-by-PR changes
Over 80 pull requests went into this release. The following people contributed
to the release:
- @0xflotus
- Aaron Ayres
- Kit Choi
- Mark Dickinson
- Chigozie Nri
- Poruri Sai Rahul
- Corran Webster
- John Wiggins
- Peter Zahemszky
Thank you to all who contributed!
Features
- The
observemini-language now supports use of"*"for listening to
all traits on aHasTraitsobject. Currently this support is limited to
cases where the"*"appears in a terminal position. For example,
observe("foo:*")is supported, butobserve("*:foo")is not.
(#1496, #1525) - The
Anytrait type now supports afactoryargument (with accompanying
argsandkwarguments). This can be used to specify a per-instance
default, for example withAny(factory=dict). (#1557, #1558) - The
DefaultValueenumeration has a new memberDefaultValue.disallow
intended to be used for trait types that don't have a meaningful default. For
traits using this default value type, an attempt to retrieve the
corresponding default usingdefault_value_forwill raiseValueError.
(#1546) - When a method is decorated with an
observedecorator, the method
signature is now checked, and a warning issued if it doesn't match the
expected signature. This should catch the common error of forgetting to
provide theeventparameter. (#1529) - In
ETSToolkit, the"qt"toolkit name is now supported as a synonym
for"qt4". (#1436) - The
Date,DatetimeandTimetrait types have a new argument
allow_none. In the future, these trait types will not acceptNone
unlessallow_none=Trueis specified. (#1432) - The
Datetrait type has a new argumentallow_datetime. In the future,
datetimeinstances will not be valid values for aDatetrait unless
allow_datetime=Trueis specified. (#1429)
Performance
- The
ObserverGraphinstances that result from compiling
ObserverExpressionobjects and observe mini-language strings are now
cached. This should speed up creation and instantiation ofHasTraits
subclasses that involve listening for the same pattern in multiple places.
(#1516, #1528) - The equality definition on
ObserverExpressionhas been simplified.
(#1517) - The
ObserverExpression,ObserverGraphand related
classes now use__slots__to improve speed and memory use. (#1513, #1515) - The
on_trait_changemethod has been sped up by almost a factor of two,
by removing unnecessary internal usage of Traits in the parsing and listener
functionality. (#1490, #1491, #1492, #1493)
Changes
- An invalid static default value in a
PrefixListorPrefixMaptrait
declaration now raisesValueErrorrather thanTraitError. (#1564) PrefixListandPrefixMapno longer cache completions. (#1564)- A failure to parse an
observemini-language string now raises
ValueErrorrather thanLarkError. (#1507) - The
NotifierNotFoundexception is now published in
traits.observation.api. (#1498) - An attempt to access a nonexistent "dunder" attribute (an attribute whose
name starts and ends with "__") on aCTraitinstance will now raise
AttributeError. Previously, it would returnNone. (#1469, #1474,
#1477)
Deprecations
- The
Anytrait type currently implicitly makes a per-HasTraits-instance
copy of the default value if that value is an instance of eitherlistor
dict. This behaviour is deprecated, and will be removed in Traits 7.0.
For a per-instance default, use the newfactoryargument toAny
instead. (#1548, #1532) - The
Date,DatetimeandTimetrait types will no longer accept
Noneas a valid trait value in the future. To keep the existing
behaviour, use the newallow_nonekeyword argument to these trait types.
(#1444) - The
Datetrait type will no longer acceptdatetimeinstances by
default in the future. To keep the existing behaviour, use the new
allow_datetimekeyword argument. (#1441) - The
Symboltrait type is deprecated. For resolution of a string
representing a package/module/object combination, useimport_symbol
instead. (#1542) - The
MetaHasTraits.add_listenerandMetaHasTraits.remove_listener
methods are deprecated. (#1550) - The
clean_filenameandclean_timestamputilities are deprecated. If
you need these utilities in your own project, you're advised to copy the
code directly into your project. (#1527) - The
find_resourceandstore_resourcefunctions are deprecated. New
code should useimportlib.resourcesorimportlib_resourcesinstead
of either of these functions. (#1501)
Fixes
- Invalid assignments to
PrefixListandPrefixMaptraits produced
an unnecessarily nested exception. This has been fixed. (#1564) - An
observe-decorated listener method whose name has the special form
"_traitname_changed"will no longer be triggered both as as result
of theobservedecorator and the special naming: it will only be
triggered via theobservedecorator. (#1560) - The
delegateparameter was mistyped in the typing stubs for the
Delegatetrait type. This has been fixed. (#1556) - The
FunctionandMethodtrait types will no longer fail when
arguments are passed. Note that these trait types are already deprecated, and
should not be used in new code. (#1543) - Inner traits of a
Uniontrait are now validated properly. Previously, in
trait declarations likefoo = Union(List(Int), Str), the list entries
would not be validated. (#1522, #1534) - Traits with a dynamic default that appear as inner traits of a
Tuple
trait are now validated properly. (#1521) - A potential race condition in
ListenerHandlerhas been fixed. The
race condition is hard to exercise and has not been witnessed in the wild.
(#1495) - Use of
add_class_traitto add aListtrait was broken in the presence
of subclasses. This has been fixed. (#1461) - A use of the (deprecated)
distutilslibrary has been replaced with
sysconfig. (#1452) - Dynamic default handing has been fixed in the
_instance_handler_factory
used by the TraitsUITableEditor. (#1446, #1450) - The trait descriptions (the "info" text) for the
FileandDirectory
traits have been fixed to avoid giving a misleading error message when
exists=True. (#1440) - Clones of
BaseInstancetraits didn't correctly respect theallow_none
parameter. This is now fixed. (#1433) - An outdated reference to the "pyglet" Kiva backend has been removed. (#1431)
Documentation
- Brief installation docs have been added. (#1559)
- Occurrences of
Any(some_list)in docs have been replaced. (#1547) - The documentation for
sync_traithas been updated to note that it only
synchronises items forListtraits, not forDictandSettraits.
(#1519) - A configuration file for Read the Docs has been added. (#1478)
- A
DeprecationWarningarising from an unnecessary override of the
add_contentmethod in theTraitDocumenterhas been fixed. (#1475) - The Sphinx version was temporarily pinned to avoid build failures arising
from bugs in Sphinx 4.0.1. That pin has since been reverted.
(#1471, #1462) - Various docstring fixes have been applied. (#1468, #1465)
- Various typo fixes have been applied. (#1458, #1442)
- References to
HasTraits.sethave been rep...