Skip to content

STYLE: Fixed redefined-outer-name linting issue #49675

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
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import (
date,
datetime,
time,
time as dt_time,
timedelta,
tzinfo,
)
Expand Down Expand Up @@ -610,7 +610,7 @@ def get_loc(self, key, method=None, tolerance=None):
f"Cannot index {type(self).__name__} with {type(key).__name__}"
)

elif isinstance(key, time):
elif isinstance(key, dt_time):
if method is not None:
raise NotImplementedError(
"cannot yet lookup inexact labels when key is a time object"
Expand Down Expand Up @@ -674,12 +674,12 @@ def slice_indexer(self, start=None, end=None, step=None):
# For historical reasons DatetimeIndex supports slices between two
# instances of datetime.time as if it were applying a slice mask to
# an array of (self.hour, self.minute, self.seconds, self.microsecond).
if isinstance(start, time) and isinstance(end, time):
if isinstance(start, dt_time) and isinstance(end, dt_time):
if step is not None and step != 1:
raise ValueError("Must have step size of 1 with time slices")
return self.indexer_between_time(start, end)

if isinstance(start, time) or isinstance(end, time):
if isinstance(start, dt_time) or isinstance(end, dt_time):
raise KeyError("Cannot mix time and non-time slice keys")

def check_str_or_none(point) -> bool:
Expand Down Expand Up @@ -1092,6 +1092,6 @@ def bdate_range(
)


def _time_to_micros(time_obj: time) -> int:
def _time_to_micros(time_obj: dt_time) -> int:
seconds = time_obj.hour * 60 * 60 + 60 * time_obj.minute + time_obj.second
return 1_000_000 * seconds + time_obj.microsecond
4 changes: 2 additions & 2 deletions pandas/io/formats/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ def add_declaration(self) -> bytes:
"""
decl = f'<?xml version="1.0" encoding="{self.encoding}"?>\n'

doc = (
docs = (
self.out_xml
if self.out_xml.startswith(b"<?xml")
else decl.encode(self.encoding) + self.out_xml
)

return doc
return docs

def remove_declaration(self) -> bytes:
"""
Expand Down
3 changes: 1 addition & 2 deletions pandas/io/json/_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
import warnings

from pandas._libs import json
from pandas._libs.json import loads
from pandas._typing import (
DtypeObj,
JSONSerializable,
Expand Down Expand Up @@ -41,7 +41,6 @@
from pandas import Series
from pandas.core.indexes.multi import MultiIndex

loads = json.loads

TABLE_SCHEMA_VERSION = "1.4.0"

Expand Down