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

PEP 678: new API for add_note() #4

Merged
merged 2 commits into from
Apr 25, 2022
Merged

Conversation

Zac-HD
Copy link
Contributor

@Zac-HD Zac-HD commented Feb 25, 2022

Just after my last PR - and after we'd asked the Steering Council to consider the PEP - we had some translation-related concerns that ended up prompting a slight redesign. So here's another PR with the new interface!

(and I'm sorry for the churn! Thanks for maintaining the backport 💖)

@Zac-HD Zac-HD force-pushed the pep-678-notes branch 4 times, most recently from 1e95fbc to 62db279 Compare February 25, 2022 07:20
Copy link
Owner

@agronholm agronholm left a comment

Choose a reason for hiding this comment

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

Add a changelog entry and we're good.

I take it that the py3.11 tests will start working with the next alpha release?

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Feb 25, 2022

I take it that the py3.11 tests will start working with the next alpha release?

Yep, should do. If you want to hold off on merging until then that's fine by me.

@agronholm
Copy link
Owner

If you compile the latest version from main and run the test suite on that and it passes, I'll agree to merge this.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Feb 26, 2022

It's currently on the Steering Council agenda and in python/cpython#31317, so holding this PR until the PEP is accepted or a 3.11 alpha released with the new API would make me more comfortable.

And again, I'm sorry for the churn! The "how can you provide localization and translation for notes" discussion thread - which prompted these changes - came up the day after I first sent this to the SC for consideration 😓

@agronholm
Copy link
Owner

Sure, let's wait until then.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 12, 2022

PEP-678 has formally been accepted (🥳), and I've updated this PR accordingly with the final design.

Once python/cpython#31317 is merged upstream, I'll confirm that the 3.11 tests pass on CPython main, and then we'll be all set for 3.11.0b1 in early May.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 20, 2022

Having drafted the Hypothesis PR I'll want to use this in, I'm also planning to add a helper function

def add_note(exc: BaseException, note: str) -> None:
    try:
        exc.add_note(note)
    except AttributeError:
        if not isinstance(note, str):
            raise TypeError(f"Note must be a string, got {type(note).__name__}")
        if not hasattr(exc, "__notes__"):
            exc.__notes__ = []
        exc.__notes__.append(note)

on the basis that either we ship it in the backport, or literally everyone who wants to use PEP-678 notes will have to implement it for themselves.

@agronholm
Copy link
Owner

Have you confirmed that this PR passes against CPython 3.11 main? If so, then I'll merge.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 21, 2022

It seems to work, though I wanted to confirm that everything plays well together over the weekend before asking you to merge and release - apologies for the delay, but I was asked to present a tutorial at PyCon next week and that's been a fairly urgent call on my OSS time.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 25, 2022

@agronholm - I've retested everything against CPython nightly locally, and it's ready to merge 🚀

Thanks again for your patience!

@agronholm agronholm merged commit 3a5efbc into agronholm:main Apr 25, 2022
@agronholm
Copy link
Owner

Thanks!

@Zac-HD Zac-HD deleted the pep-678-notes branch April 25, 2022 07:07
@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 25, 2022

Nice! Ping me when you release on PyPI?

@agronholm
Copy link
Owner

Done.

@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 25, 2022

Awesome!

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