From 1cea33fa2ab6995ebfaebb93748a59597efb9d72 Mon Sep 17 00:00:00 2001 From: Jacques Raphanel Date: Thu, 4 Jun 2026 20:25:49 +0000 Subject: [PATCH] chore: update black --- .github/workflows/ci.yml | 9 ++- .pre-commit-config.yaml | 2 +- codecov.yml | 20 ++++++ .../persistence/mssql/reader.py | 64 +++++-------------- pyproject.toml | 1 + requirements-lint.txt | 2 +- 6 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 589991d..7644b3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,14 @@ jobs: - name: Install package and test dependencies run: pip install -e ".[all]" pytest pytest-cov - name: Run unit + cli tests - run: pytest tests/unit tests/cli --cov=db2sql --cov-fail-under=80 + run: pytest tests/unit tests/cli --cov=db2sql --cov-report=xml --cov-report=term --cov-fail-under=80 + - name: Upload coverage to Codecov + if: ${{ !cancelled() }} + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + fail_ci_if_error: false docs: name: Build documentation diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c529a9..e9a9a32 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/commitizen-tools/commitizen diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..b58bee8 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,20 @@ +coverage: + status: + project: + default: + target: auto + threshold: 1% + patch: + default: + target: 80% + threshold: 0% + +comment: + layout: "reach, diff, flags, files" + behavior: default + require_changes: false + +ignore: + - "tests/**" + - "docs/**" + - "installer/**" diff --git a/db2sql/infrastructure/persistence/mssql/reader.py b/db2sql/infrastructure/persistence/mssql/reader.py index a4659cb..c12c5ff 100644 --- a/db2sql/infrastructure/persistence/mssql/reader.py +++ b/db2sql/infrastructure/persistence/mssql/reader.py @@ -82,9 +82,7 @@ def iter_query_rows(self, query: str, limit: int = -1) -> Iterator[Tuple[Any, .. def _read_schemas(self, database: Database) -> None: try: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA s @@ -95,9 +93,7 @@ def _read_schemas(self, database: Database) -> None: ) ORDER BY SCHEMA_NAME -""" - ) - ) +""")) except Exception as exc: raise SourceReaderError(f"Error connecting to database {exc}") from exc @@ -105,9 +101,7 @@ def _read_schemas(self, database: Database) -> None: database.add_schema(Schema(row.SCHEMA_NAME)) def _read_tables(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.tables @@ -116,16 +110,12 @@ def _read_tables(self, database: Database) -> None: AND TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams') ORDER BY TABLE_SCHEMA, TABLE_NAME -""" - ) - ) +""")) for row in r: database.add_table(row.TABLE_SCHEMA, Table(row.TABLE_NAME)) def _read_columns(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT TABLE_SCHEMA, TABLE_NAME, @@ -140,9 +130,7 @@ def _read_columns(self, database: Database) -> None: INFORMATION_SCHEMA.COLUMNS ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION -""" - ) - ) +""")) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) @@ -160,18 +148,14 @@ def _read_columns(self, database: Database) -> None: ) def _read_computed_columns(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT S.NAME TABLE_SCHEMA, T.NAME TABLE_NAME, C.NAME COLUMN_NAME, C.DEFINITION FROM SYS.COMPUTED_COLUMNS C INNER JOIN SYS.TABLES T ON T.OBJECT_ID = C.OBJECT_ID INNER JOIN SYS.SCHEMAS S ON S.SCHEMA_ID = T.SCHEMA_ID - """ - ) - ) + """)) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) @@ -181,9 +165,7 @@ def _read_computed_columns(self, database: Database) -> None: column.computed_definition = row.DEFINITION def _read_identity_columns(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT s.name TABLE_SCHEMA, o.name TABLE_NAME, c.name COLUMN_NAME @@ -194,9 +176,7 @@ def _read_identity_columns(self, database: Database) -> None: ON o.schema_id = s.schema_id WHERE s.name NOT IN ('sys') ORDER BY 1, 2, 3 - """ - ) - ) + """)) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) @@ -206,18 +186,14 @@ def _read_identity_columns(self, database: Database) -> None: column.identity = True def _read_column_constraints(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT u.TABLE_SCHEMA, u.TABLE_NAME, u.COLUMN_NAME, c.CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE u INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS c ON c.CONSTRAINT_NAME = u.CONSTRAINT_NAME AND c.CONSTRAINT_SCHEMA = u.CONSTRAINT_SCHEMA WHERE c.CONSTRAINT_TYPE IN ('UNIQUE', 'PRIMARY KEY') - """ - ) - ) + """)) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) @@ -227,9 +203,7 @@ def _read_column_constraints(self, database: Database) -> None: column.constraint = row.CONSTRAINT_TYPE def _read_foreign_keys(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT KCU1.CONSTRAINT_SCHEMA AS CONSTRAINT_SCHEMA, KCU1.CONSTRAINT_NAME AS CONSTRAINT_NAME, KCU1.TABLE_SCHEMA AS TABLE_SCHEMA, @@ -253,9 +227,7 @@ def _read_foreign_keys(self, database: Database) -> None: WHERE KCU1.ORDINAL_POSITION = KCU2.ORDINAL_POSITION AND KCU1.TABLE_SCHEMA not in ('sys', 'guest', 'information_schema') ORDER BY CONSTRAINT_SCHEMA, CONSTRAINT_NAME - """ - ) - ) + """)) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) @@ -269,9 +241,7 @@ def _read_foreign_keys(self, database: Database) -> None: ) def _read_indexes(self, database: Database) -> None: - r: engine.Result[Any] = self._ensure_session().execute( - text( - """ + r: engine.Result[Any] = self._ensure_session().execute(text(""" SELECT sch.name as TABLE_SCHEMA, t.name as TABLE_NAME, ind.name as INDEX_NAME, @@ -295,9 +265,7 @@ def _read_indexes(self, database: Database) -> None: AND t.is_ms_shipped = 0 AND sch.name not in ('sys', 'guest', 'information_schema') ORDER BY t.name, ind.name, ind.index_id, ic.index_column_id - """ - ) - ) + """)) for row in r: table = database.get_table(row.TABLE_SCHEMA, row.TABLE_NAME) diff --git a/pyproject.toml b/pyproject.toml index c867eff..43e7d74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,6 +69,7 @@ repository = "http://github.com/sismicfr/python-db2sql.git" [tool.black] line-length = 100 +target-version = ["py39"] [flake8] exclude = [".git",".venv",".tox","dist","docs","*egg,build"] diff --git a/requirements-lint.txt b/requirements-lint.txt index f2f3971..ba98b91 100644 --- a/requirements-lint.txt +++ b/requirements-lint.txt @@ -1,6 +1,6 @@ -r requirements.txt build==1.2.1 -black==24.10.0 +black==26.3.1 commitizen==3.31.0 flake8==7.1.1 import-linter==2.1