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

change labels() method return type #58

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

pradishb
Copy link

@pradishb pradishb commented Oct 5, 2024

fix #57

Copy link
Owner

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

👋 hi, thanks a lot for catching this issue and the contribution!

Due to having to support older versions of python I think the best course of action would be to use the typing_extensions library to make direct use of Self.

From my tests using "Self" would still mark it as unknown for pyright the returned object (although it fixes the error on the method).

Let me know if you want to work on it further or if you prefer for me to take over, regardless of choice I really appreciate you taking the time for raising and fixing this 🙌

So to recap the course of action would be:

  1. Add a dependency to typing_extensions
  2. Import Self without the need for the TYP_CHECKING check
  3. Replace "Self" -> Self

pytheus/metrics.py Outdated Show resolved Hide resolved
pytheus/metrics.py Outdated Show resolved Hide resolved
@pradishb
Copy link
Author

I agree that using typing_extensions is the better solution. I have made the requested changes,

Copy link
Owner

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

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

Looks good! 🙌
Thank you for your contribution 🙇

@Llandy3d
Copy link
Owner

it actually doesn't seem to be enough as the return type now mismatch 😭

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.

labels() returns _Metric type instead of Self
2 participants