Skip to content

TYPING: add type hints to pandas\io\formats\printing.py #27579

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

Conversation

simonjayhawkins
Copy link
Member

No description provided.

@simonjayhawkins simonjayhawkins added Output-Formatting __repr__ of pandas objects, to_string 2/3 Compat Typing type annotations, mypy/pyright type checking labels Jul 25, 2019

from pandas._config import get_option

from pandas.core.dtypes.inference import is_sequence


def adjoin(space, *lists, **kwargs):
def adjoin(space: int, *lists: str, **kwargs) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean all the lists are strings?

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch. should be List[str]. will update.

sep = str(sep)
return sep.join([x.decode("utf-8") if isinstance(x, str) else x for x in lines])
def _join_unicode(lines: Iterable[str], sep: str = "") -> str:
return sep.join(lines)
Copy link
Member

Choose a reason for hiding this comment

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

Likely no longer needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

only used in two places. inline and remove?

@jreback jreback added this to the 1.0 milestone Jul 25, 2019
@jreback
Copy link
Contributor

jreback commented Jul 25, 2019

lgtm. @WillAyd

if hasattr(obj, "dtype") and include_dtype:
attrs.append(("dtype", "'{}'".format(obj.dtype)))
# error: "Sequence[Any]" has no attribute "dtype"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm this type of introspection is going to be interesting with annotations. Something to think about moving forward

Copy link
Member Author

Choose a reason for hiding this comment

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

@WillAyd WillAyd merged commit 5b1a870 into pandas-dev:master Jul 25, 2019
@WillAyd
Copy link
Member

WillAyd commented Jul 25, 2019

Thanks @simonjayhawkins !

@simonjayhawkins simonjayhawkins deleted the pandas-io-formats-printing.py branch July 26, 2019 03:18
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants