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

Make Jenkins implement AbstractAsyncContextManager + Improve tests/README to use it #34

Merged
merged 7 commits into from
Aug 18, 2024

Conversation

PaarthShah
Copy link
Contributor

@PaarthShah PaarthShah commented Aug 10, 2024

I was using this for a project, and I didn't like having to write try...finally: await jenkins.close().
This is the idiomatic way to setup/close resources such as this, and I'd love to see this merged/published to pypi if possible! Tests all pass locally (including with 3.7 3.8, the minimum supported version of python for this project).

README.rst Show resolved Hide resolved
@@ -64,7 +65,7 @@ async def close(self) -> None:
await self.session.close()


class Jenkins:
class Jenkins(AbstractAsyncContextManager):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Subclassing this automatically provides the default __aenter__ method (which returns self)

setup.cfg Show resolved Hide resolved
@@ -184,5 +171,3 @@ async def test_make_jenkins_version(jenkins, aiohttp_mock):
)
version = await jenkins.get_version()
assert version == JenkinsVersion(major=2, minor=346, patch=1, build=4)

await jenkins.close()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seemed like a stray call to close and tests passed without it

@coveralls
Copy link
Collaborator

coveralls commented Aug 10, 2024

Coverage Status

coverage: 93.744% (-0.3%) from 94.072%
when pulling d983044 on PaarthShah:async-context-manager
into 29700e5 on pbelskiy:master.

@PaarthShah
Copy link
Contributor Author

@pbelskiy Would this be good to merge along with a version bump? 👀

@pbelskiy pbelskiy merged commit e6237b3 into pbelskiy:master Aug 18, 2024
12 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.

3 participants