-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mypy complaints about TraitError (#1658)
Projects using traits-stubs reported that mypy was complaining about not having information about TraitError. This PR should fix that. I've also added some instructions on local development to the README, since I have to figure this out every time. (cherry picked from commit 4f17157)
- Loading branch information
1 parent
f4935b5
commit ad1a337
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# (C) Copyright 2020-2022 Enthought, Inc., Austin, TX | ||
# All rights reserved. | ||
# | ||
# This software is provided without warranty under the terms of the BSD | ||
# license included in LICENSE.txt and may be redistributed only under | ||
# the conditions described in the aforementioned license. The license | ||
# is also available online at http://www.enthought.com/licenses/BSD.txt | ||
# | ||
# Thanks for using Enthought open source! | ||
|
||
""" | ||
A selection of code snippets used to test completeness of the stubs. | ||
""" | ||
|
||
from traits.api import HasStrictTraits, Str, TraitError | ||
|
||
|
||
class HasName(HasStrictTraits): | ||
name = Str() | ||
|
||
|
||
def try_assigning_age(x: HasName, new_name: str): | ||
try: | ||
x.age = new_name | ||
except TraitError: | ||
raise ValueError(f"Bad age: {new_name}") |