Skip to content

TYP: added missing __init__ in pandas/core/methods #51052

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
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ repos:
types: [python]
stages: [manual]
additional_dependencies: &pyright_dependencies
- [email protected].276
- [email protected].284
Copy link
Member Author

Choose a reason for hiding this comment

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

There are more errors with 1.1.291 microsoft/pyright#4546

- id: pyright_reportGeneralTypeIssues
# note: assumes python env is setup and activated
name: pyright reportGeneralTypeIssues
Expand Down
9 changes: 8 additions & 1 deletion pandas/_testing/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
)
import uuid

from pandas._typing import (
BaseBuffer,
CompressionOptions,
FilePath,
)
from pandas.compat import PYPY
from pandas.errors import ChainedAssignmentError

Expand All @@ -20,7 +25,9 @@


@contextmanager
def decompress_file(path, compression) -> Generator[IO[bytes], None, None]:
def decompress_file(
path: FilePath | BaseBuffer, compression: CompressionOptions
) -> Generator[IO[bytes], None, None]:
"""
Open a compressed file and return a file object.

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -9540,7 +9540,7 @@ def _append(

def join(
self,
other: DataFrame | Series | list[DataFrame | Series],
other: DataFrame | Series | Iterable[DataFrame | Series],
on: IndexLabel | None = None,
how: MergeHow = "left",
lsuffix: str = "",
Expand Down
Empty file added pandas/core/methods/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion pandas/core/window/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def flex_binary_moment(arg1, arg2, f, pairwise: bool = False):
elif isinstance(arg1, ABCDataFrame):
from pandas import DataFrame

def dataframe_from_int_dict(data, frame_template):
def dataframe_from_int_dict(data, frame_template) -> DataFrame:
result = DataFrame(data, index=frame_template.index)
if len(result.columns) > 0:
result.columns = frame_template.columns[result.columns]
Expand Down
12 changes: 7 additions & 5 deletions pandas/io/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ class BadLineHandleMethod(Enum):
def __init__(self, kwds) -> None:

self.names = kwds.get("names")
self.orig_names: list | None = None
self.orig_names: Sequence[Hashable] | None = None

self.index_col = kwds.get("index_col", None)
self.unnamed_cols: set = set()
self.index_names: Sequence[Hashable] | None = None
self.col_names = None
self.col_names: Sequence[Hashable] | None = None

self.parse_dates = _validate_parse_dates_arg(kwds.pop("parse_dates", False))
self._parse_date_cols: Iterable = []
Expand Down Expand Up @@ -269,9 +269,11 @@ def _should_parse_dates(self, i: int) -> bool:
def _extract_multi_indexer_columns(
self,
header,
index_names: list | None,
index_names: Sequence[Hashable] | None,
passed_names: bool = False,
):
) -> tuple[
Sequence[Hashable], Sequence[Hashable] | None, Sequence[Hashable] | None, bool
]:
"""
Extract and return the names, index_names, col_names if the column
names are a MultiIndex.
Expand Down Expand Up @@ -1004,7 +1006,7 @@ def _validate_usecols_arg(self, usecols):
return usecols, usecols_dtype
return usecols, None

def _clean_index_names(self, columns, index_col):
def _clean_index_names(self, columns, index_col) -> tuple[list | None, list, list]:
if not is_index_col(index_col):
return None, columns, index_col

Expand Down
3 changes: 1 addition & 2 deletions pandas/io/parsers/c_parser_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ def __init__(self, src: ReadCsvBuffer[str], **kwds) -> None:

# error: Cannot determine type of 'names'
if self.names is None: # type: ignore[has-type]
# error: Cannot determine type of 'names'
self.names = list(range(self._reader.table_width)) # type: ignore[has-type]
self.names = list(range(self._reader.table_width))

# gh-9755
#
Expand Down
3 changes: 1 addition & 2 deletions pandas/io/parsers/python_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def __init__(self, f: ReadCsvBuffer[str] | list, **kwds) -> None:
# Now self.columns has the set of columns that we will process.
# The original set is stored in self.original_columns.
# error: Cannot determine type of 'index_names'
self.columns: list[Hashable]
(
self.columns,
self.index_names,
Expand Down Expand Up @@ -915,7 +914,7 @@ def _clear_buffer(self) -> None:
_implicit_index = False

def _get_index_name(
self, columns: list[Hashable]
self, columns: Sequence[Hashable]
) -> tuple[Sequence[Hashable] | None, list[Hashable], list[Hashable]]:
"""
Try several cases to get lines:
Expand Down