Skip to content

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented May 13, 2020

To enable type-checking we would like to enable mypy onto the python code :)

import logging

import fastavro
import fastavro # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to be needed for every import that doesn't use type annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes for now, or we can disable it. More and more packages will have types in the future :)

visit(write_schema, CheckCompatibility(read_schema, False))

NO_ERRORS = []
NO_ERRORS: List[str] = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also be a tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant was: should this be tuple() because it is a constant and should not be mutable?

@rdblue
Copy link
Contributor

rdblue commented May 13, 2020

Overall, I'm +1 for this change because it should help us keep quality high. I'm going to leave this open for a little while to let @TGooch44, @rymurr, and @xhochy take a look at comment since adding a type checker affects Python contributors.

@rymurr
Copy link
Contributor

rymurr commented May 18, 2020

Overall, I'm +1 for this change because it should help us keep quality high. I'm going to leave this open for a little while to let @TGooch44, @rymurr, and @xhochy take a look at comment since adding a type checker affects Python contributors.

I am 👍 as well. I am not a huge fan of the visual distractions and verbosity of mypy annotations however once integrated into CI it should pull its weight.

Copy link
Member

@xhochy xhochy left a comment

Choose a reason for hiding this comment

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

+1, this definitely helps to detect some subtle errors. I would though set --ignore-missing-imports instead of the numerous # type: ignore on third-party imports.

@rdblue
Copy link
Contributor

rdblue commented May 18, 2020

@Fokko, could you use --ignore-missing-imports to cut down on the number of files that are modified?

@Fokko
Copy link
Contributor Author

Fokko commented May 21, 2020

I've updated the tox command. I've also pulled in the latest master to make sure that it works with latest master.

@Fokko
Copy link
Contributor Author

Fokko commented May 21, 2020

Thanks all for the review. I agree that it makes the code a bit more verbose, but this makes it also more accessible for newcomers 👍

@rdblue
Copy link
Contributor

rdblue commented May 21, 2020

Merging. Thanks for adding this, @Fokko!

@rdblue rdblue merged commit 3ca6cc3 into apache:master May 21, 2020
@Fokko Fokko deleted the fd-add-mypy branch November 17, 2022 13:34
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.

4 participants