enthought / enthought/traits

HasStrictTraits class sets dunder values when passed to constructor

Open
#378 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Consider this example

```
>>> class Foo(HasStrictTraits):
... a = Int()
>>> Foo(whatever=5)
Traceback (most recent call last):
File "", line 1, in
traits.trait_errors.TraitError: Cannot set the undefined 'whatever' attribute of a 'Foo' object.
>>> x=Foo(__foo__=4)
>>> x.trait_names()
['a', 'trait_added', 'trait_modified', '__foo__']
```

I would expect to refuse it in either case.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.