mirror of
https://github.com/open-metadata/OpenMetadata
synced 2026-05-24 09:39:11 +00:00
* chore(ingestion): drop pylint, expand ruff to Stage 2c
Replace pylint with a coherent ruff-only stack (Stage 2c of the modernize
roadmap). Pylint is dropped from dev deps and CI workflows; ruff selected
ruleset expanded to ~22 families covering style, bug catchers, hygiene,
and the pylint port (PLE/PLC/PLW/PLR with the noisy "too-many-X"
complexity caps + magic-value disabled).
What's selected (with rationale in pyproject.toml):
E, W, F, I, N — style + correctness baseline + naming
UP — pyupgrade (py>=3.10 modernizations)
B, C4, C90, RET, SIM, TRY — bug catchers
PIE, ICN, T20, TC, TID, PTH, PERF — hygiene
PLE, PLC, PLW, PLR — pylint port (PLR complexity caps ignored)
RUF — ruff-native (incl. RUF100 unused-noqa)
What's removed:
- .pylintrc (root) — duplicate of the ingestion pylint config
- [tool.pylint.*] block in ingestion/pyproject.toml (~140 lines)
- ingestion/plugins/{print_checker,import_checker}.py + tests + README
(replaced by built-in T20 + TID251 banned-api respectively)
- pylint dep from ingestion/setup.py and openmetadata-airflow-apis/pyproject.toml
- `make lint` Makefile target + the pylint invocation in py_format_check
- dead pylint TODO comment + ignored test entry in noxfile.py
Cwd-stable config: ruff is invoked both from the repo root (pre-commit,
CI) and from ingestion/ (`make py_format_check`). The `src`,
`extend-exclude`, and per-file-ignores entries are listed twice — once
relative to ingestion/ and once with the `ingestion/` prefix — so
first-party isort detection and exclusions match in both invocations.
Grandfathering: ran `ruff check --add-noqa` once + format-stable
iteration. ~12,130 noqa directives across ~1,400 files. Cleanup is
deferred to follow-up PRs that drop noqas one rule at a time.
Documentation sweep: replaced `make lint` references in CLAUDE.md,
AGENTS.md, DEVELOPER.md, copilot-instructions, and 6 SKILL files with
the apply+verify shape `make py_format && make py_format_check`.
`make py_format` is NOT a strict superset of pylint — it only applies
auto-fixable violations; `make py_format_check` catches the rest.
Basedpyright baseline regenerated: ruff format reflowed multi-line
signatures in ~70 files, shifting type-error column positions. The
basedpyright baseline matches by (file path, error code, range), so
column shifts caused 19 entries to mis-align. Net diff is small
(154 lines in/out of the 13MB baseline.json) — purely positional.
Verified locally:
- make py_format_check → All checks passed
- nox --no-venv -s static-checks → 0 errors, 0 warnings, 0 notes
* chore(ingestion): finish ruff swap — nox lint session + skill docs
Three remaining stale-tooling references after Stage 2c:
- `ingestion/noxfile.py` `lint` session was still calling `black --check`,
`isort --check-only`, `pycln --diff`. Those tools aren't installed
anywhere (we dropped them from dev deps). Replace with the ruff
equivalents that mirror `make py_format_check`.
- `skills/standards/code_style.md`: stack listed as `black + isort +
pycln`; line length claimed 88 (black default). Both wrong: stack is
ruff, line length is 120.
- `skills/connector-building/SKILL.md`: `make py_format` comment said
`# black + isort + pycln`. Same swap.
* chore(ingestion): keep main's baseline + globally ignore TRY400
Per gitar-bot's review on PR #27774:
1. Main's PR #27728 promoted ~60 `logger.warning()` → `logger.error()`
inside `except` blocks. Those changes landed on main with their own
baseline updates. Our PR doesn't promote anything — the merge from
origin/main brought those `error` calls along with their baseline
entries.
The bot interpreted the `# noqa: TRY400` we added next to those lines
as us silencing the rule case-by-case. Cleaner: globally ignore
TRY400 in pyproject.toml, with a comment explaining why the codebase's
`logger.error(...)` + separate `logger.debug(traceback.format_exc())`
pattern is intentional. Strip ~430 per-line `# noqa: TRY400` markers
from source.
2. Document that `S101` in `per-file-ignores` is a forward-looking
entry — flake8-bandit (`S`) is not yet selected, so the rule is
no-op today; the entry stays so when `S` lands later, tests don't
immediately error.
Reverts the platform pin and Linux Docker–generated baseline. Keep
main's baseline intact and let CI surface the exact column-shifted
entries; the team will decide whether to fix in-place (revert format
on affected files) or add per-line `# pyright: ignore` markers.
* chore(ingestion): regen baseline for new connector type debt
Main's baseline was stale relative to recently-added connectors
(McpConnection, CustomDriveConnection) that lack common attributes
like `hostPort`, `database`, `catalog` etc. — all sites that access
those attributes via the union-typed `serviceConnection.root.config`
fire `reportAttributeAccessIssue` errors that aren't baselined.
71 errors + 58 warnings absorbed. Local macOS regen; pushing to see
CI's drift count. Per the basedpyright-baseline-and-ci PR experience,
macOS↔Linux column drift on this size of regen has historically been
1-7 residuals.
149 lines
4.2 KiB
Python
149 lines
4.2 KiB
Python
# Copyright 2022 Collate
|
|
# Licensed under the Collate Community License, Version 1.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
# https://github.com/open-metadata/OpenMetadata/blob/main/ingestion/LICENSE
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""
|
|
Test Postgres connector with CLI
|
|
"""
|
|
|
|
from typing import List # noqa: UP035
|
|
|
|
from .common.test_cli_db import CliCommonDB # noqa: TID252
|
|
from .common_e2e_sqa_mixins import SQACommonMethods # noqa: TID252
|
|
|
|
|
|
class PostgresCliTest(CliCommonDB.TestSuite, SQACommonMethods):
|
|
create_table_query: str = """
|
|
CREATE TABLE IF NOT EXISTS public.all_datatypes (
|
|
column1 bigint,
|
|
column2 bigserial,
|
|
column5 boolean,
|
|
column6 character(10),
|
|
column7 character varying(10),
|
|
column8 date,
|
|
column9 double precision,
|
|
column10 integer,
|
|
column11 interval,
|
|
column12 json,
|
|
column13 jsonb,
|
|
column14 numeric(10,2),
|
|
column15 real,
|
|
column16 smallint,
|
|
column17 smallserial,
|
|
column28 serial,
|
|
column29 text,
|
|
column20 time without time zone,
|
|
column21 time with time zone,
|
|
column22 timestamp without time zone,
|
|
column23 timestamp with time zone,
|
|
column24 uuid
|
|
);
|
|
"""
|
|
|
|
create_view_query: str = """
|
|
CREATE OR REPLACE VIEW public.view_all_datatypes AS
|
|
SELECT *
|
|
FROM public.all_datatypes;
|
|
"""
|
|
|
|
insert_data_queries: List[str] = [ # noqa: RUF012, UP006
|
|
"""
|
|
INSERT INTO public.all_datatypes VALUES (
|
|
1,
|
|
2,
|
|
true,
|
|
'abcdefghij',
|
|
'abcdefghij',
|
|
'2022-08-08',
|
|
1234.5678,
|
|
1234567890,
|
|
'1 day 2 hours 3 minutes 4 seconds'::interval,
|
|
'{"a":1,"b":2}',
|
|
'{"a":1,"b":2}',
|
|
1234.56,
|
|
1234.5678::real,
|
|
32767::smallint,
|
|
32767,
|
|
2147483647,
|
|
'abcdefghij',
|
|
'12:34:56'::time without time zone ,
|
|
'12:34:56+02'::time with time zone ,
|
|
'2022-08-08 12:34:56'::timestamp without time zone ,
|
|
'2022-08-08 12:34:56+02'::timestamp with time zone ,
|
|
'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid
|
|
)""",
|
|
]
|
|
|
|
drop_table_query: str = """
|
|
DROP TABLE IF EXISTS public.all_datatypes;
|
|
"""
|
|
|
|
drop_view_query: str = """
|
|
DROP VIEW IF EXISTS public.view_all_datatypes;
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_connector_name() -> str:
|
|
return "postgres"
|
|
|
|
def create_table_and_view(self) -> None:
|
|
SQACommonMethods.create_table_and_view(self)
|
|
|
|
def delete_table_and_view(self) -> None:
|
|
SQACommonMethods.delete_table_and_view(self)
|
|
|
|
@staticmethod
|
|
def expected_tables() -> int:
|
|
return 2
|
|
|
|
def expected_sample_size(self) -> int:
|
|
return len(self.insert_data_queries)
|
|
|
|
def view_column_lineage_count(self) -> int:
|
|
return 22
|
|
|
|
def expected_lineage_node(self) -> str:
|
|
return "local_postgres.E2EDB.public.view_all_datatypes"
|
|
|
|
@staticmethod
|
|
def fqn_created_table() -> str:
|
|
return "local_postgres.E2EDB.public.all_datatypes"
|
|
|
|
@staticmethod
|
|
def get_includes_schemas() -> List[str]: # noqa: UP006
|
|
return ["public"]
|
|
|
|
@staticmethod
|
|
def get_includes_tables() -> List[str]: # noqa: UP006
|
|
return [".*all_datatypes.*"]
|
|
|
|
@staticmethod
|
|
def get_excludes_tables() -> List[str]: # noqa: UP006
|
|
return [".*test_empty.*"]
|
|
|
|
@staticmethod
|
|
def expected_filtered_schema_includes() -> int:
|
|
return 1
|
|
|
|
@staticmethod
|
|
def expected_filtered_schema_excludes() -> int:
|
|
return 1
|
|
|
|
@staticmethod
|
|
def expected_filtered_table_includes() -> int:
|
|
return 66
|
|
|
|
@staticmethod
|
|
def expected_filtered_table_excludes() -> int:
|
|
return 0
|
|
|
|
@staticmethod
|
|
def expected_filtered_mix() -> int:
|
|
return 2
|