deprecate reconnect in Connection.ping()#1241
Conversation
There was a problem hiding this comment.
Pull request overview
Changes the default of Connection.ping()'s reconnect parameter from True to False, documents the argument as deprecated, and updates the CHANGELOG to reflect this as a breaking change in v1.2.0 (removing it from the "planned" section).
Changes:
- Flip default of
Connection.ping(reconnect=...)fromTruetoFalse. - Document
reconnectas deprecated in the docstring. - Move the entry from "planned" changes to the v1.2.0 "Breaking changes" section in CHANGELOG.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pymysql/connections.py | Changes default for reconnect to False and notes deprecation in docstring. |
| CHANGELOG.md | Moves the ping(reconnect) entry from planned changes to the v1.2.0 breaking changes section, noting deprecation of the argument. |
Comments suppressed due to low confidence (1)
pymysql/connections.py:611
- The docstring and CHANGELOG state that
reconnectis deprecated, but passingreconnect=Truedoes not emit aDeprecationWarning. Other recently deprecated arguments in this codebase (e.g.,dbandpasswdinconnect()) emit aDeprecationWarningso users have a clear signal to migrate. Consider emitting aDeprecationWarninghere whenreconnectis truthy (or when it is explicitly passed) so callers relying on the old behavior get a runtime warning.
def ping(self, reconnect=False):
"""
Check if the server is alive.
`reconnect` is deprecated. Create a new connection if you want to reconnect.
:param reconnect: If the connection is closed, reconnect.
:type reconnect: boolean
:raise Error: If the connection is closed and reconnect=False.
"""
if self._sock is None:
if reconnect:
self.connect()
reconnect = False
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1241 +/- ##
==========================================
- Coverage 86.24% 84.38% -1.87%
==========================================
Files 17 17
Lines 2436 2466 +30
Branches 258 247 -11
==========================================
- Hits 2101 2081 -20
- Misses 249 307 +58
+ Partials 86 78 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.