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

Enable call stack logging for deprecation warnings (optional) #2406

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

Badiboy
Copy link
Collaborator

@Badiboy Badiboy commented Oct 20, 2024

Description

I found that for some deprecations I cannot find where it happens to fix it.

2024-10-20 14:41:27,885 (types.py:9267 Thread-12442 (process_request_thread)) WARNING - TeleBot: "Deprecation warning: the filed "from_user" is not accessible for InaccessibleMessage. You should check if your object is Message instance before access."
2024-10-20 14:41:27,885 (types.py:9267 Thread-12442 (process_request_thread)) WARNING - TeleBot: "Deprecation warning: the filed "from_user" is not accessible for InaccessibleMessage. You should check if your object is Message instance before access."
2024-10-20 14:42:31,599 (types.py:9267 Thread-13476 (process_request_thread)) WARNING - TeleBot: "Deprecation warning: the filed "from_user" is not accessible for InaccessibleMessage. You should check if your object is Message instance before access."
2024-10-20 14:42:31,599 (types.py:9267 Thread-13476 (process_request_thread)) WARNING - TeleBot: "Deprecation warning: the filed "from_user" is not accessible for InaccessibleMessage. You should check if your object is Message instance before access."

Thus I propose to add an option that will enable call stack logging for deprecations, so developer can find the reason.

@coder2020official
Copy link
Collaborator

I'm sure there is a better way of implementing this, but I can't take a look at this issue right now

@Badiboy
Copy link
Collaborator Author

Badiboy commented Oct 20, 2024

I'm not in a hurry with this. Please, take a look when you will have time.
If you have better idea - let me know )

@Badiboy
Copy link
Collaborator Author

Badiboy commented Oct 26, 2024

@coder2020official I'm not in a hurry, but I really need this in reasonable time )

@coder2020official
Copy link
Collaborator

Hi, I couldn't really come up with a far better implementation, but at least I propose doing this:

  • creating a function called log_deprecation_warning, which will accept a string warning and return nothing; inside, it will output warning, check for constant value, and if needed, output another warning.

@Badiboy
Copy link
Collaborator Author

Badiboy commented Nov 3, 2024

@coder2020official refactored.

@Badiboy Badiboy merged commit 9b0db41 into eternnoir:master Nov 15, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants