Skip to content

CLN: assorted #48385

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 3 commits into from
Sep 12, 2022
Merged

CLN: assorted #48385

merged 3 commits into from
Sep 12, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

end: Timestamp | None,
periods: int | None,
offset: BaseOffset,
):
Copy link
Member

Choose a reason for hiding this comment

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

Confused why the default value for offset got dropped?

Copy link
Member Author

Choose a reason for hiding this comment

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

bc this is never called without passing offset (outside tests, which this changes)

@@ -1916,7 +1916,7 @@ def _drop_labels_or_levels(self, keys, axis: int = 0):
# Perform copy upfront and then use inplace operations below.
# This ensures that we always perform exactly one copy.
# ``copy`` and/or ``inplace`` options could be added in the future.
dropped = self.copy()
dropped = self.copy(deep=False)
Copy link
Member

Choose a reason for hiding this comment

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

Just trying to be explicit with copy instead of relying on signature defaults?

Copy link
Member Author

Choose a reason for hiding this comment

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

this improves perf by avoiding making an actual copy. safe since this method is private

@gfyoung gfyoung added the Clean label Sep 4, 2022
@mroeschke
Copy link
Member

mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

pandas/core/arrays/datetimes.py:2528: error: Argument 1 to "Timestamp" has incompatible type "Optional[Timestamp]"; expected "Union[integer[Any], float, str, date, datetime64]"  [arg-type]
pandas/core/arrays/datetimes.py:2529: error: Non-overlapping identity check (left operand type: "Timestamp", right operand type: "NaTType")  [comparison-overlap]
pandas/core/arrays/datetimes.py:2530: error: Argument 1 to "Timestamp" has incompatible type "Optional[Timestamp]"; expected "Union[integer[Any], float, str, date, datetime64]"  [arg-type]
pandas/core/arrays/datetimes.py:2531: error: Non-overlapping identity check (left operand type: "Timestamp", right operand type: "NaTType")  [comparison-overlap]
pandas/core/arrays/datetimes.py:2534: error: Incompatible types in assignment (expression has type "datetime", variable has type "Optional[Timestamp]")  [assignment]
pandas/core/arrays/datetimes.py:2537: error: Incompatible types in assignment (expression has type "datetime", variable has type "Optional[Timestamp]")  [assignment]
pandas/core/arrays/datetimes.py:2539: error: Unsupported operand types for < ("Timestamp" and "None")  [operator]
pandas/core/arrays/datetimes.py:2539: error: Unsupported operand types for > ("Timestamp" and "None")  [operator]
pandas/core/arrays/datetimes.py:2539: error: Unsupported left operand type for < ("None")  [operator]
pandas/core/arrays/datetimes.py:2539: note: Both left and right operands are unions
pandas/core/arrays/datetimes.py:2544: error: No overload variant of "__radd__" of "BaseOffset" matches argument type "None"  [operator]
pandas/core/arrays/datetimes.py:2544: note: Possible overload variants:
pandas/core/arrays/datetimes.py:2544: note:     def __radd__(self, ndarray[Any, dtype[object_]]) -> ndarray[Any, dtype[object_]]
pandas/core/arrays/datetimes.py:2544: note:     def __radd__(self, BaseOffset) -> BaseOffset
pandas/core/arrays/datetimes.py:2544: note:     def [_DatetimeT <: datetime] __radd__(self, _DatetimeT) -> _DatetimeT
pandas/core/arrays/datetimes.py:2544: note:     def [_TimedeltaT <: timedelta] __radd__(self, _TimedeltaT) -> _TimedeltaT
pandas/core/arrays/datetimes.py:2544: note: Left operand is of type "Optional[Timestamp]"
pandas/core/arrays/datetimes.py:2544: error: Unsupported operand types for - ("None" and "int")  [operator]
pandas/core/arrays/datetimes.py:2544: note: Left operand is of type "Optional[int]"
pandas/core/arrays/datetimes.py:2547: error: Unsupported operand types for - ("None" and "int")  [operator]
pandas/core/arrays/datetimes.py:2547: note: Left operand is of type "Optional[int]"
pandas/core/arrays/datetimes.py:2560: error: "BaseOffset" has no attribute "_apply"  [attr-defined]
pandas/core/arrays/datetimes.py:2574: error: "BaseOffset" has no attribute "_apply"  [attr-defined]
Found 14 errors in 1 file (checked 1398 source files)

@jbrockmendel
Copy link
Member Author

mypy fixed, just an unrelated timeout remaining

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Looks okay to me cc @gfyoung if you have any additional comments.

@mroeschke mroeschke added this to the 1.6 milestone Sep 12, 2022
@mroeschke mroeschke merged commit 51396d8 into pandas-dev:main Sep 12, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the fixmes56 branch September 12, 2022 18:32
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
* CLN: assorted

* mypy fixup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants