Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Verify collection type in TypedStruct #57

Merged
merged 1 commit into from
Jan 21, 2018

Conversation

idanarye
Copy link

To prevent things like this:

In [1]: from easypy import typed_struct as ts

In [2]: class Foo(ts.TypedStruct):
   ...:     bars = [str]
   ...:

In [3]: Foo(bars='hello')
Out[3]:
Foo(bars=['h',
          'e',
          'l',
          'l',
          'o'])

@idanarye idanarye requested a review from koreno January 18, 2018 14:40
@idanarye idanarye force-pushed the typed-dict-verify-collection-type branch from 49d914a to 848fe5b Compare January 18, 2018 14:49
with pytest.raises(ts.FieldCollectionTypeMismatch):
Foo(b=['9'])

# Test TypedBunch:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch?

Copy link
Contributor

@koreno koreno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!
you can fix that comment and merge

To prevent things like this:

```python
In [1]: from easypy import typed_struct as ts

In [2]: class Foo(ts.TypedStruct):
   ...:     bars = [str]
   ...:

In [3]: Foo(bars='hello')
Out[3]:
Foo(bars=['h',
          'e',
          'l',
          'l',
          'o'])
```
@idanarye idanarye force-pushed the typed-dict-verify-collection-type branch from 848fe5b to ea7285f Compare January 21, 2018 17:29
@idanarye idanarye merged commit 4a134cf into master Jan 21, 2018
@YuvalEvron YuvalEvron deleted the typed-dict-verify-collection-type branch August 6, 2019 08:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants