Skip to content

Enable mypy on Python - #1041

Merged
rdblue merged 4 commits into
apache:masterfrom
Fokko:fd-add-mypy
May 21, 2020
Merged

Enable mypy on Python#1041
rdblue merged 4 commits into
apache:masterfrom
Fokko:fd-add-mypy

Conversation

@Fokko

@Fokko Fokko commented May 13, 2020

Copy link
Copy Markdown
Contributor

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

Comment thread python/iceberg/core/manifest_reader.py Outdated
import logging

import fastavro
import fastavro # type: ignore

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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

rdblue commented May 13, 2020

Copy link
Copy Markdown
Contributor

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

rymurr commented May 18, 2020

Copy link
Copy Markdown
Contributor

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.

@xhochy xhochy left a comment

Copy link
Copy Markdown
Member

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

rdblue commented May 18, 2020

Copy link
Copy Markdown
Contributor

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

@Fokko

Fokko commented May 21, 2020

Copy link
Copy Markdown
Contributor Author

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

@Fokko

Fokko commented May 21, 2020

Copy link
Copy Markdown
Contributor Author

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

rdblue commented May 21, 2020

Copy link
Copy Markdown
Contributor

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