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

Instance of 'DatetimeIndex' has no 'to_pydatetime' member Pylint (E1101:no-member) #10166

Open
Aria-AAs opened this issue Jan 3, 2025 · 0 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@Aria-AAs
Copy link

Aria-AAs commented Jan 3, 2025

Bug description

Code Responsible for Error Reproduction:

from datetime import datetime, timezone
from pandas import date_range

start = datetime(2023, 1, 1, tzinfo=timezone.utc)
end = datetime.now(timezone.utc).replace(second=0, microsecond=0)
intervals = (
    date_range(start, end, freq="MS").to_pydatetime().tolist() # E1101:no-member
)
print(intervals)

The output of the code:

[datetime.datetime(2023, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 2, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 3, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 4, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 5, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 6, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 7, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 8, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 9, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 10, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 11, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2023, 12, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 2, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 3, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 5, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 6, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 7, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 8, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 9, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 10, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 11, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 12, 1, 0, 0, tzinfo=datetime.timezone.utc), datetime.datetime(2025, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)]

Description:

Pylint generates an error indicating that the return type of the date_range function in the pandas library, which is a DatetimeIndex, does not contain a method member named to_pydatetime. However, it is my understanding that such a member does exist. The code operates as intended, yet the pylint error persists.

Additionally, I have seen a similar issue that appears to have been addressed in the past.
The similar issue

Command used

pylint ./test.py

Pylint output

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:7:4: E1101: Instance of 'DatetimeIndex' has no 'to_pydatetime' member (no-member)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

Expected behavior

I did not expect to encounter a no-member error when a member is present.

Python version

Python version 3.13.1

Pylint version

Pylint version 3.3.3

OS / Environment

Linux Mint 22 cinnamon

Additional dependencies

Pandas==2.2.3
@Aria-AAs Aria-AAs added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

1 participant