Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

Users cannot suppress the RuntimeWarning about using default CasbinRule table. The warning parameter doesn't work as intended and the warning itself adds no value since users are explicitly choosing to use the default or custom table.

Changes

  • Removed warning parameter from Adapter.__init__()
  • Removed warning emission code that displayed RuntimeWarning when db_class=None
  • Removed unused warnings import

Example

Before:

# Warning appears regardless of parameter
adapter = Adapter(engine)  # RuntimeWarning emitted
adapter = Adapter(engine, warning=False)  # RuntimeWarning still emitted
adapter = Adapter(engine, db_class=CasbinRule)  # RuntimeWarning still emitted

After:

# No warnings emitted
adapter = Adapter(engine)
adapter = Adapter(engine, db_class=CustomRule)

The adapter continues to work with both default CasbinRule and custom database classes without emitting warnings.

Original prompt

This section details on the original issue you should resolve

<issue_title>Cant suppress warning</issue_title>
<issue_description>I don't know what has happened to the version in Pypi but it's not matching the version here.

I can't seem to suppress this warning

 RuntimeWarning: Using default CasbinRule table, please note the use of the 'Adapter().create_table()' method to create the table, and ignore this warning if you are using a custom CasbinRule table.

I tried passing db_class. Still got a warning. Setting warning=False, still got a warning. Both, still got a warning.

Checked the code that was downloaded from pypi. Doesn't have the warning param. </issue_description>

Comments on the Issue (you are @copilot in this section)

@nomeguy need to fix the bugs and remove the warning code introduced in commit: https://github.com/officialpycasbin/async-sqlalchemy-adapter/commit/a785acc1c987a3a16317ed1f8376600ef3ceb179

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@nomeguy nomeguy marked this pull request as ready for review November 21, 2025 06:38
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix warning suppression in database adapter Remove warning parameter and suppression code from Adapter Nov 21, 2025
Copilot AI requested a review from nomeguy November 21, 2025 06:43
@nomeguy nomeguy changed the title Remove warning parameter and suppression code from Adapter feat: remove warning parameter and suppression code from Adapter Nov 21, 2025
@nomeguy nomeguy merged commit 682252a into master Nov 21, 2025
13 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 21, 2025
# [1.14.0](v1.13.0...v1.14.0) (2025-11-21)

### Features

* remove warning parameter and suppression code from Adapter ([#19](#19)) ([456a940](456a940))
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.

Cant suppress warning

2 participants