Skip to content

ANN: types for _create_storer #29757

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

Merged
merged 6 commits into from
Nov 25, 2019
Merged

Conversation

jbrockmendel
Copy link
Member

  1. Annotate return type for _create_storer
  2. Annotate other functions that we can reason about given 1
  3. Fixups to address mypy warnings caused by 1 and 2

except KeyError:
error("_TYPE_MAP")
raise error("_TYPE_MAP")
Copy link
Member

Choose a reason for hiding this comment

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

will this make sense now that _TYPE_MAP is inlined?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could inline the thing here too

@simonjayhawkins
Copy link
Member

@jbrockmendel looking good. Union["GenericFixed", "Table"] used 4 times. not sure we have a policy for when we should use an alias, i.e. number of occurrences vs complexity of type expression.

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Nov 20, 2019
@simonjayhawkins simonjayhawkins added this to the 1.0 milestone Nov 20, 2019
@jbrockmendel
Copy link
Member Author

used 4 times

In this case I think they're better kept as the Union. In a perfect world id like to get separate functions one of which returns Table and the other returns GenericFixed, but i couldn't come up with a nice way of pre-checking

@jreback
Copy link
Contributor

jreback commented Nov 21, 2019

i think i merged in an odd order, pls rebase

@jreback
Copy link
Contributor

jreback commented Nov 22, 2019

merged lots of stuff, can you rebase just to be sure here.

@jbrockmendel
Copy link
Member Author

rebased+green

where=where, start=start, stop=stop, **kwargs
)
tbl = self.get_storer(key)
if not isinstance(tbl, Table):
Copy link
Member

Choose a reason for hiding this comment

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

Does doing this solve a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

mypy mostly. get_storer can return two different types, and this method only works if we get a Table back

@jreback jreback merged commit 2fbfa30 into pandas-dev:master Nov 25, 2019
@jreback
Copy link
Contributor

jreback commented Nov 25, 2019

k thanks

@jbrockmendel jbrockmendel deleted the cln-pytables8 branch November 25, 2019 23:16
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants