Skip to content
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

TYP: simplify read_csv/fwf/table overloads #57476

Merged
merged 5 commits into from Feb 21, 2024

Conversation

twoertwein
Copy link
Member

No description provided.

keep_default_na: bool = True,
na_filter: bool = True,
verbose: bool | lib.NoDefault = lib.no_default,
skip_blank_lines: bool = True,
# Datetime Handling
parse_dates: bool | Sequence[Hashable] = False,
parse_dates: bool | Sequence[Hashable] | None = None,
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what to do here: None of the three methods document None but it is the default in read_csv.

A few options:

  • Document it, but keep it False in read_table (and add a deprecation warning, that it will be None in the future)
  • Document it, change it to None in read_table (might need a deprecationwarnign first? edit: could probably directly change it with 3.0 but add a whatsnew entry?)
  • Disallow None, add a deprecation warning in the other methods

Copy link
Member

Choose a reason for hiding this comment

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

Document it, change it to None in read_table (might need a deprecationwarnign first? edit: could probably directly change it with 3.0 but add a whatsnew entry?)

I would support this and mark it as an Other API changes

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, the current commits already do that :)

"infer_nrows": infer_nrows,
"engine": "python-fwf",
"iterator": iterator,
"chunksize": chunksize,
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 doesn't like assigning new fields to a TypedDict

@@ -478,6 +479,59 @@ class _Fwf_Defaults(TypedDict):
widths: None


class _read_shared(TypedDict, total=False):
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure whether this should move to _typing?

@twoertwein twoertwein marked this pull request as ready for review February 18, 2024 02:09
@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label Feb 19, 2024
@@ -1488,17 +1163,6 @@ def read_fwf(
infer_nrows : int, default 100
The number of rows to consider when letting the parser determine the
`colspecs`.
dtype_backend : {'numpy_nullable', 'pyarrow'}, default 'numpy_nullable'
Copy link
Member

Choose a reason for hiding this comment

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

Did this get moved somewhere else?

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 moved it into the kwds to share it among the read-functions. The doc-test was failing as it did not find the corresponding keyword in the function signature anymore.

@mroeschke mroeschke added this to the 3.0 milestone Feb 21, 2024
@mroeschke mroeschke merged commit 5870057 into pandas-dev:main Feb 21, 2024
50 of 51 checks passed
@mroeschke
Copy link
Member

Thanks @twoertwein

@twoertwein twoertwein deleted the read_overloads branch April 7, 2024 10:59
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* TYP: simplify read_csv/fwf/table overloads

* isort (keep thinking ruff is configured to do that too)

* another one

* fix docs?

* sort whatsnew entry
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.

None yet

2 participants