Skip to content

Commit

Permalink
ref: use stdlib warnings module instead of a third party dependency (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile-sentry committed Apr 12, 2024
1 parent 41aff04 commit 37ac4c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions google/cloud/spanner_dbapi/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from google.cloud.spanner_dbapi.cursor import Cursor
from google.cloud.spanner_v1 import RequestOptions
from google.cloud.spanner_v1.snapshot import Snapshot
from deprecated import deprecated

from google.cloud.spanner_dbapi.exceptions import (
InterfaceError,
Expand Down Expand Up @@ -187,10 +186,11 @@ def autocommit_dml_mode(self):
return self._autocommit_dml_mode

@property
@deprecated(
reason="This method is deprecated. Use _spanner_transaction_started field"
)
def inside_transaction(self):
warnings.warn(
"This method is deprecated. Use _spanner_transaction_started field",
DeprecationWarning,
)
return (
self._transaction
and not self._transaction.committed
Expand Down
7 changes: 5 additions & 2 deletions google/cloud/spanner_dbapi/parse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
import datetime
import decimal
import re
import warnings

import sqlparse
from google.cloud import spanner_v1 as spanner
from google.cloud.spanner_v1 import JsonObject
from . import client_side_statement_parser
from deprecated import deprecated

from .exceptions import Error
from .parsed_statement import ParsedStatement, StatementType, Statement
Expand Down Expand Up @@ -179,14 +179,17 @@
RE_PYFORMAT = re.compile(r"(%s|%\([^\(\)]+\)s)+", re.DOTALL)


@deprecated(reason="This method is deprecated. Use _classify_stmt method")
def classify_stmt(query):
"""Determine SQL query type.
:type query: str
:param query: A SQL query.
:rtype: str
:returns: The query type name.
"""
warnings.warn(
"This method is deprecated. Use _classify_stmt method", DeprecationWarning
)

# sqlparse will strip Cloud Spanner comments,
# still, special commenting styles, like
# PostgreSQL dollar quoted comments are not
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"sqlparse >= 0.4.4",
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'",
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
"deprecated >= 1.2.14",
"grpc-interceptor >= 0.15.4",
]
extras = {
Expand Down

0 comments on commit 37ac4c1

Please sign in to comment.