Skip to content

TYP: to_csv accepts IO[bytes] and fix FilePathOrBuffer #41903

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
Jun 10, 2021
Merged

TYP: to_csv accepts IO[bytes] and fix FilePathOrBuffer #41903

merged 2 commits into from
Jun 10, 2021

Conversation

twoertwein
Copy link
Member

@twoertwein twoertwein commented Jun 9, 2021

Two small typing fixes:

  • to_csv accepts IO[bytes] (replace FilePathOrBuffer[str] with FilePathOrBuffer[AnyStr])
  • pyright was not able to parse FilePathOrBuffer because the unconstrained TypeVar pandas._typing.T was used when the constrained TyepVar typing.AnyStr should have been used: Could not specialize type "Buffer[AnyStr@Buffer]"   Type "T@FileOrBuffer" is incompatible with constrained type variable "AnyStr"

@twoertwein
Copy link
Member Author

the macOS run failed because it timed out
image

@simonjayhawkins simonjayhawkins added IO CSV read_csv, to_csv Typing type annotations, mypy/pyright type checking labels Jun 10, 2021
@jreback jreback added this to the 1.3 milestone Jun 10, 2021
@jreback jreback merged commit 4d549cb into pandas-dev:master Jun 10, 2021
@jreback
Copy link
Contributor

jreback commented Jun 10, 2021

thanks @twoertwein

@twoertwein twoertwein mentioned this pull request Jun 11, 2021
@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Jun 11, 2021

It seems that the mac build started failing with this PR (it's failing now on master consistently since this PR, and I didn't notice any change in versions of dependencies in the build environment that might otherwise explain it).

Above it was mentioned that the Mac build timed out, but the last commit actually has the failing build without time out.

It's a bit strange (and didn't look further in detail, just reporting here), the actual tests seems to pass (pytest prints the end result), but then there is:

ci/run_tests.sh: line 31:  2533 Segmentation fault: 11  sh -c "$PYTEST_CMD"
##[error]Bash exited with code '139'.

Although nothing in the diff of this PR would explain a new failure, though

@jorisvandenbossche
Copy link
Member

There is also a

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "pyarrow/types.pxi", line 2638, in pyarrow.lib._unregister_py_extension_types
SystemError: unregister_extension_type() method: bad call flags

in the output

@jorisvandenbossche
Copy link
Member

Noticed there is already an issue about it -> #41937

JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO CSV read_csv, to_csv Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants