Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion web/pgadmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ def get_locale():
##########################################################################
if config.CONFIG_DATABASE_URI is not None and \
len(config.CONFIG_DATABASE_URI) > 0:
app.config['SQLALCHEMY_DATABASE_URI'] = config.CONFIG_DATABASE_URI
_db_uri = re.sub(
r"^postgres(ql)?://", "postgresql+psycopg://",
config.CONFIG_DATABASE_URI, count=1
)
app.config['SQLALCHEMY_DATABASE_URI'] = _db_uri
else:
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}?timeout={1}' \
.format(config.SQLITE_PATH.replace('\\', '/'),
Expand Down
6 changes: 6 additions & 0 deletions web/pgadmin/utils/check_external_config_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#
##########################################################################

import re

from sqlalchemy import create_engine, inspect


Expand All @@ -15,6 +17,10 @@ def check_external_config_db(database_uri):
Check if external config database exists if it
is being used.
"""
if database_uri.startswith(("postgresql://", "postgres://")):
database_uri = re.sub(
r"^postgres(ql)?://", "postgresql+psycopg://", database_uri, count=1
)
Comment on lines +21 to +23
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix pycodestyle E501 on Line 22 (currently failing CI).

The substitution call exceeds the configured line length limit; wrapping arguments resolves the pipeline failure without changing behavior.

Proposed fix
     if database_uri.startswith(("postgresql://", "postgres://")):
         database_uri = re.sub(
-            r"^postgres(ql)?://", "postgresql+psycopg://", database_uri, count=1
+            r"^postgres(ql)?://",
+            "postgresql+psycopg://",
+            database_uri,
+            count=1,
         )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
database_uri = re.sub(
r"^postgres(ql)?://", "postgresql+psycopg://", database_uri, count=1
)
database_uri = re.sub(
r"^postgres(ql)?://",
"postgresql+psycopg://",
database_uri,
count=1,
)
🧰 Tools
🪛 GitHub Actions: Check Python style

[error] 22-22: pycodestyle reported [E501] line too long (80 > 79 characters).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/pgadmin/utils/check_external_config_db.py` around lines 21 - 23, The
re.sub call that assigns database_uri exceeds the line length; break the
arguments across multiple lines to satisfy pycodestyle E501 without changing
behavior. Locate the assignment to database_uri where re.sub is called and
format it like: re.sub( pattern, replacement, database_uri, count=1 ) with each
argument on its own line (or pattern/replacement on one line and
database_uri/count on the next) so the long line is wrapped but the regex,
replacement string ("postgresql+psycopg://") and count=1 are unchanged.

engine = create_engine(database_uri)
try:
connection = engine.connect()
Expand Down
Loading