Skip to content

TYP: sas, stata, style #36990

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 5 commits into from
Oct 10, 2020
Merged

TYP: sas, stata, style #36990

merged 5 commits into from
Oct 10, 2020

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@jreback jreback added the Typing type annotations, mypy/pyright type checking label Oct 8, 2020
@jreback jreback added this to the 1.2 milestone Oct 8, 2020
@@ -63,11 +64,21 @@ def _convert_datetimes(sas_datetimes: pd.Series, unit: str) -> pd.Series:


class _subheader_pointer:
pass
def __init__(self, offset, length, compression, ptype):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you defin the types? (alt you can define attributes on the class)

@@ -63,11 +64,21 @@ def _convert_datetimes(sas_datetimes: pd.Series, unit: str) -> pd.Series:


class _subheader_pointer:
Copy link
Contributor

Choose a reason for hiding this comment

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

while why are at it, shouldn't these follow pep?

else:
buf = path_or_buf

self._path_or_buf: IO[Any] = buf
Copy link
Contributor

Choose a reason for hiding this comment

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

define as a class attribute?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

some requests i think are worth doing here

# mypy doesnt like dynamically-defined class
# error: Variable "cls" is not valid as a type [valid-type]
# error: Invalid base class "cls" [misc]
class MyStyler(cls): # type:ignore[valid-type,misc]
Copy link
Contributor

Choose a reason for hiding this comment

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

does this resolve if using an appropriate constructor like: https://docs.python.org/3.7/library/types.html (or the old type constructor)

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 didnt know that types.new_class was a thing. id rather keep the more-idiomatic usage even if mypy doesnt like it

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

pass

class _Column:
col_id: int
Copy link
Contributor

Choose a reason for hiding this comment

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

could be a dataclass to avoid this repetition

@jreback
Copy link
Contributor

jreback commented Oct 10, 2020

fair, merge on green-ish

@jreback jreback merged commit a1e5304 into pandas-dev:master Oct 10, 2020
@jreback
Copy link
Contributor

jreback commented Oct 10, 2020

followups appreciated here

@jbrockmendel jbrockmendel deleted the typ-io branch October 10, 2020 18:08
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
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.

2 participants