Get a ``dict`` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. This method is just like the :meth:`traits` method, but is unbound. The TraitTypes returned don't know anything about the values that the v
(cls: type[HasTraits], **metadata: t.Any)
| 1782 | |
| 1783 | @classmethod |
| 1784 | def class_traits(cls: type[HasTraits], **metadata: t.Any) -> dict[str, TraitType[t.Any, t.Any]]: |
| 1785 | """Get a ``dict`` of all the traits of this class. The dictionary |
| 1786 | is keyed on the name and the values are the TraitType objects. |
| 1787 | |
| 1788 | This method is just like the :meth:`traits` method, but is unbound. |
| 1789 | |
| 1790 | The TraitTypes returned don't know anything about the values |
| 1791 | that the various HasTrait's instances are holding. |
| 1792 | |
| 1793 | The metadata kwargs allow functions to be passed in which |
| 1794 | filter traits based on metadata values. The functions should |
| 1795 | take a single value as an argument and return a boolean. If |
| 1796 | any function returns False, then the trait is not included in |
| 1797 | the output. If a metadata key doesn't exist, None will be passed |
| 1798 | to the function. |
| 1799 | """ |
| 1800 | traits = cls._traits.copy() |
| 1801 | |
| 1802 | if len(metadata) == 0: |
| 1803 | return traits |
| 1804 | |
| 1805 | result = {} |
| 1806 | for name, trait in traits.items(): |
| 1807 | for meta_name, meta_eval in metadata.items(): |
| 1808 | if not callable(meta_eval): |
| 1809 | meta_eval = _SimpleTest(meta_eval) |
| 1810 | if not meta_eval(trait.metadata.get(meta_name, None)): |
| 1811 | break |
| 1812 | else: |
| 1813 | result[name] = trait |
| 1814 | |
| 1815 | return result |
| 1816 | |
| 1817 | @classmethod |
| 1818 | def class_own_traits( |