Skip to content

deprecate reconnect in Connection.ping()#1241

Merged
methane merged 4 commits into
PyMySQL:mainfrom
methane:ping-no-reconnect
May 18, 2026
Merged

deprecate reconnect in Connection.ping()#1241
methane merged 4 commits into
PyMySQL:mainfrom
methane:ping-no-reconnect

Conversation

@methane
Copy link
Copy Markdown
Member

@methane methane commented May 18, 2026

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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=...) from True to False.
  • Document reconnect as 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 reconnect is deprecated, but passing reconnect=True does not emit a DeprecationWarning. Other recently deprecated arguments in this codebase (e.g., db and passwd in connect()) emit a DeprecationWarning so users have a clear signal to migrate. Consider emitting a DeprecationWarning here when reconnect is 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
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.38%. Comparing base (1e28be8) to head (b708544).
⚠️ Report is 49 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@methane methane merged commit 7349a44 into PyMySQL:main May 18, 2026
13 checks passed
@methane methane deleted the ping-no-reconnect branch May 18, 2026 15:57
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