Skip to content
Merged
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
34 changes: 21 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description = "PostgreSQL Tuning and Analysis Tool"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"mcp[cli]>=1.8.0",
"psycopg[binary]>=3.2.6",
"humanize>=4.8.0",
"pglast==7.2.0",
"attrs>=25.3.0",
"psycopg-pool>=3.2.6",
"instructor>=1.7.9",
"mcp[cli]>=1.25.0",
"psycopg[binary]>=3.3.2",
"humanize>=4.15.0",
"pglast==7.11",
"attrs>=25.4.0",
"psycopg-pool>=3.3.0",
"instructor>=1.14.4",
]
license = "mit"
license-files = ["LICENSE"]
Expand All @@ -38,18 +38,18 @@ asyncio_default_fixture_loop_scope = "function"
[dependency-groups]
dev = [
"docker>=7.1.0",
"pyright==1.1.398",
"pytest-asyncio>=0.26.0",
"pytest>=8.3.5",
"ruff==0.11.2",
"pyright==1.1.408",
"pytest-asyncio>=1.3.0",
"pytest>=9.0.2",
"ruff==0.14.13",
]

[tool.black]
line-length = 150

[tool.ruff]
line-length = 150
target-version = "py38"
target-version = "py39"
exclude = [".venv*"]

lint.select = [
Expand All @@ -65,6 +65,15 @@ lint.select = [
"RUF" # ruff-specific rules
]

# TODO: Remove these ignores when fixing #129 (code modernization)
lint.ignore = [
"UP006", # Use `list` instead of `List` for type annotations
"UP035", # Import from `collections.abc` instead of `typing`
"UP045", # Use `X | None` instead of `Optional[X]`
"RUF059", # Unused unpacked variable
"RUF100", # Unused noqa directive
]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
Expand All @@ -80,7 +89,6 @@ known-first-party = ["postgres-mcp"]
[tool.pyright]
typeCheckingMode = "standard"
pythonVersion = "3.12"
strictParameterNullChecking = true
reportMissingTypeStubs = false
# reportUnknownMemberType = true
# reportUnknownParameterType = true
Expand Down
16 changes: 10 additions & 6 deletions tests/unit/sql/test_readonly_enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ async def test_force_readonly_enforcement():
mock_execute.return_value = [SqlDriver.RowResult(cells={"test": "value"})]

# Test UNRESTRICTED mode
with patch("postgres_mcp.server.current_access_mode", AccessMode.UNRESTRICTED), patch(
"postgres_mcp.server.db_connection", mock_conn_pool
), patch.object(SqlDriver, "_execute_with_connection", mock_execute):
with (
patch("postgres_mcp.server.current_access_mode", AccessMode.UNRESTRICTED),
patch("postgres_mcp.server.db_connection", mock_conn_pool),
patch.object(SqlDriver, "_execute_with_connection", mock_execute),
):
driver = await get_sql_driver()
assert isinstance(driver, SqlDriver)
assert not isinstance(driver, SafeSqlDriver)
Expand All @@ -55,9 +57,11 @@ async def test_force_readonly_enforcement():
assert mock_execute.call_args[1]["force_readonly"] is False

# Test RESTRICTED mode
with patch("postgres_mcp.server.current_access_mode", AccessMode.RESTRICTED), patch(
"postgres_mcp.server.db_connection", mock_conn_pool
), patch.object(SqlDriver, "_execute_with_connection", mock_execute):
with (
patch("postgres_mcp.server.current_access_mode", AccessMode.RESTRICTED),
patch("postgres_mcp.server.db_connection", mock_conn_pool),
patch.object(SqlDriver, "_execute_with_connection", mock_execute),
):
driver = await get_sql_driver()
assert isinstance(driver, SafeSqlDriver)

Expand Down
Loading