Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clean strict optional] Fix another 32 errors #3265

Merged
merged 2 commits into from
Apr 27, 2017

Conversation

ilevkivskyi
Copy link
Member

This cleans --strict-optional for:

  • treetransform.py
  • typeanal.py
  • maptype.py
  • errors.py

There are still 2 errors in the last one, but one of them is a typeshed issue (will report it tomorrow), and another should be fixed when @elazarg will finish #1855.

There is something interesting that I have noticed: there are around 150 errors only because Instance.type has type Optional[TypeInfo]. However, it could be None only right after de-serialization. It seems that these 150 errors could be fixed either by tweaking de-serialization (use a temporary class NotReadyInstance?) or just add "semi-automatically" some 150 asserts.

@JukkaL
Copy link
Collaborator

JukkaL commented Apr 27, 2017

I've noticed the Instance.type issue myself, and it would be better to have a dummy TypeInfo than None. With this change, if the dummy value is accidentally used somewhere, it will be obvious where the value is from, whereas a None value could come from anywhere. One way to do this would be to have the dummy value raise an exception on any attribute access.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for helping us move towards strict optional! Feel to merge as is, or fix the Instance.type issue first.

@ilevkivskyi
Copy link
Member Author

I think it will be easier to merge this now and make a dedicated PR for Instance.type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants