Skip to content

TYP: mostly missing return annotations in IO #44801

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 2 commits into from
Dec 28, 2021
Merged

TYP: mostly missing return annotations in IO #44801

merged 2 commits into from
Dec 28, 2021

Conversation

twoertwein
Copy link
Member

No description provided.

@twoertwein twoertwein added the Typing type annotations, mypy/pyright type checking label Dec 7, 2021
def to_clipboard(obj, excel=True, sep=None, **kwargs): # pragma: no cover
def to_clipboard(
obj, excel: bool | None = True, sep: str | None = None, **kwargs
) -> None: # pragma: no cover
Copy link
Member Author

Choose a reason for hiding this comment

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

is # pragma: no cover for codecov? Does it need to be on the def to_clipboard-line?

@@ -170,7 +170,7 @@ def _expand_user(filepath_or_buffer: str | BaseBufferT) -> str | BaseBufferT:
return filepath_or_buffer


def validate_header_arg(header) -> None:
def validate_header_arg(header: object) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

should be Any?

Copy link
Member Author

Choose a reason for hiding this comment

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

Typeshed recommends to use Any when it is too difficult to create a type annotations. object should be used if literally any object can be accepted.

https://github.com/python/typeshed/blob/master/CONTRIBUTING.md#conventions

Note that Any is not the correct type to use if you want to indicate that some function can accept literally anything: in those cases use object instead.

@@ -116,6 +116,7 @@ def _get_skiprows(skiprows: int | Sequence[int] | slice | None):
start, step = skiprows.start or 0, skiprows.step or 1
return list(range(start, skiprows.stop, step))
elif isinstance(skiprows, numbers.Integral) or is_list_like(skiprows):
assert skiprows is not None
Copy link
Member

Choose a reason for hiding this comment

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

can you make this a cast? that way mypy will alert us once it is unnecessary

@jreback jreback added this to the 1.4 milestone Dec 28, 2021
@jreback jreback merged commit 4b77cbe into pandas-dev:master Dec 28, 2021
@twoertwein twoertwein deleted the typi_io branch March 9, 2022 02:56
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.

3 participants