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

Refactor connection classes #107

Merged
merged 20 commits into from
Aug 18, 2024
Merged

Conversation

stankudrow
Copy link
Contributor

@stankudrow stankudrow commented Aug 10, 2024

This PR entails the PR #106 .

The features brought:

  • The asynch.Connection class get more unburden: now its parse_dsn() method is moved aside into the standalone util function. The reasons are as follows: 1) having DSN parsing logic in one place that may be used not only by the asynch.Connection class instances; 2) it can be tested "per se", not needing the asynch.Connection class being instantiated first.
  • The asynch.Connection class can support the interface of an asynchronous context manager: no more necessity for making an end-user invoking the connect() method and remember to call the close() method for resource clean-up.
  • the asynch.Connection gets a semi-implicit created state (status). It can be seen as the result of calling the __repr__() method on a created connection (cn = Connection(...) which were not neither opened nor closed. When created, if the cn.closed is False, then we can falsely assume that it was closed somewhere before which can be not this case. The same reasoning when the cn.connected is False - was it connected before or not? But when created and cn.connected and cn.closed are None, we understand that the connection were neither opened nor closed. For more details, please see the PR Update project dependencies and metadata #106 .

Other non-critical feature:

  • the minimum pytest version is 7.4.4 or higher. The minimum version is 7.4 to be used with Python3.9.

The tests were run under the Python v3.9, however the .python-version file is added into the .gitignore file because the project is expected to be run in multiple virtual environments. Apart introducing the mypy package, intoxicating the project with the tox testing tool would be nice, but in one of the next PRs.

@stankudrow
Copy link
Contributor Author

stankudrow commented Aug 11, 2024

@long2ice , all checks have been passed, shall we review this PR?

UPD: Done, the PR is considered final and ready for code review.

@stankudrow
Copy link
Contributor Author

stankudrow commented Aug 18, 2024

@long2ice , let's have this PR reviewed?

@long2ice
Copy link
Owner

Thanks!

@long2ice long2ice merged commit 4c52ecd into long2ice:dev Aug 18, 2024
1 check 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