Skip to content

Commit

Permalink
feat(deps): Bump latest supported sqlalchemy from 1.* to 2.* (#1484)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Edgar Ramírez Mondragón <edgar@meltano.com>
  • Loading branch information
dependabot[bot] and edgarrmondragon authored Jul 20, 2023
1 parent 384cff7 commit b5cc805
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 34 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ env:

jobs:
tests:
name: Test on ${{ matrix.python-version }} (${{ matrix.session }}) / ${{ matrix.os }}
name: "Test on ${{ matrix.python-version }} (${{ matrix.session }}) / ${{ matrix.os }} / SQLAlchemy: ${{ matrix.sqlalchemy }}"
runs-on: ${{ matrix.os }}
env:
NOXSESSION: ${{ matrix.session }}
Expand All @@ -47,9 +47,11 @@ jobs:
session: [tests]
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
sqlalchemy: ["2.*"]
include:
- { session: doctest, python-version: "3.10", os: "ubuntu-latest" }
- { session: mypy, python-version: "3.8", os: "ubuntu-latest" }
- { session: tests, python-version: "3.11", os: "ubuntu-latest", sqlalchemy: "1.*" }
- { session: doctest, python-version: "3.10", os: "ubuntu-latest", sqlalchemy: "2.*" }
- { session: mypy, python-version: "3.8", os: "ubuntu-latest", sqlalchemy: "2.*" }

steps:
- name: Check out the repository
Expand Down Expand Up @@ -86,6 +88,8 @@ jobs:
nox --version
- name: Run Nox
env:
SQLALCHEMY_VERSION: ${{ matrix.sqlalchemy }}
run: |
nox --python=${{ matrix.python-version }}
Expand Down
11 changes: 8 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ def tests(session: Session) -> None:
session.install(".[s3]")
session.install(*test_dependencies)

sqlalchemy_version = os.environ.get("SQLALCHEMY_VERSION")
if sqlalchemy_version:
# Bypass nox-poetry use of --constraint so we can install a version of
# SQLAlchemy that doesn't match what's in poetry.lock.
session.poetry.session.install( # type: ignore[attr-defined]
f"sqlalchemy=={sqlalchemy_version}",
)

try:
session.run(
"coverage",
Expand All @@ -95,9 +103,6 @@ def tests(session: Session) -> None:
"-v",
"--durations=10",
*session.posargs,
env={
"SQLALCHEMY_WARN_20": "1",
},
)
finally:
if session.interactive:
Expand Down
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ memoization = ">=0.3.2,<0.5.0"
jsonpath-ng = "^1.5.3"
joblib = "^1.0.1"
inflection = "^0.5.1"
sqlalchemy = "^1.4"
sqlalchemy = ">=1.4,<3.0"
python-dotenv = ">=0.20,<0.22"
typing-extensions = "^4.2.0"
simplejson = "^3.17.6"
Expand Down Expand Up @@ -109,7 +109,6 @@ numpy = [
{ version = ">=1.22", python = ">=3.8" },
]
requests-mock = "^1.10.0"
sqlalchemy2-stubs = {version = "^0.0.2a32", allow-prereleases = true}
types-jsonschema = "^4.17.0.6"
types-python-dateutil = "^2.8.19"
types-pytz = ">=2022.7.1.2,<2024.0.0.0"
Expand All @@ -132,9 +131,6 @@ exclude = ".*simpleeval.*"

[tool.pytest.ini_options]
addopts = '-vvv --ignore=singer_sdk/helpers/_simpleeval.py -m "not external"'
filterwarnings = [
"error::sqlalchemy.exc.RemovedIn20Warning",
]
markers = [
"external: Tests relying on external resources",
"windows: Tests that only run on Windows",
Expand Down Expand Up @@ -190,9 +186,6 @@ fail_under = 82
[tool.mypy]
exclude = "tests"
files = "singer_sdk"
plugins = [
"sqlalchemy.ext.mypy.plugin",
]
python_version = "3.8"
warn_unused_configs = true
warn_unused_ignores = true
Expand Down
6 changes: 1 addition & 5 deletions singer_sdk/sinks/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,7 @@ def bulk_insert_records(
if isinstance(insert_sql, str):
insert_sql = sqlalchemy.text(insert_sql)

conformed_records = (
[self.conform_record(record) for record in records]
if isinstance(records, list)
else (self.conform_record(record) for record in records)
)
conformed_records = [self.conform_record(record) for record in records]
self.logger.info("Inserting with SQL: %s", insert_sql)
with self.connector._connect() as conn, conn.begin():
conn.execute(insert_sql, conformed_records)
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import typing as t

import pytest
from sqlalchemy import __version__ as sqlalchemy_version

from singer_sdk import typing as th
from singer_sdk.sinks import BatchSink
Expand Down Expand Up @@ -39,6 +40,11 @@ def pytest_runtest_setup(item):
pytest.skip(f"cannot run on platform {system}")


def pytest_report_header() -> list[str]:
"""Return a list of strings to be displayed in the header of the report."""
return [f"sqlalchemy: {sqlalchemy_version}"]


@pytest.fixture(scope="class")
def outdir() -> t.Generator[str, None, None]:
"""Create a temporary directory for cookiecutters and target output."""
Expand Down

0 comments on commit b5cc805

Please sign in to comment.