ci(lint): type-check the ADF SDK and generated schema classes in lint jobs

SH
1d ago
+40-2

Summary

Two CI lint jobs type-check code against packages that are not installed, so mypy (with ignore_missing_imports) sees that code as Any and real type errors pass. This PR closes both gaps.

  • python-lint / :metadata-ingestion:lint: the [dev] venv did not install azure-mgmt-datafactory, so the whole Azure Data Factory source and its unit tests were checked against Any. 85 errors in adf_probe.py and tests/unit/azure_data_factory/test_adf_source.py were invisible. This adds the azure-data-factory plugin to the plugin list in base_dev_requirements, the same place every other type-checked plugin's SDK is installed.
  • smoke-test-lint / :smoke-test:pythonLint: the task did not depend on :metadata-ingestion:codegen, so datahub.metadata.schema_classes did not exist in a fresh CI checkout and every generated aspect class was Any. That hid an error in smoke-test/tests/e2e/knowledge/test_okf_reimport.py:127. pythonLint and pythonLintFix now depend on codegen, like stackFreePytest already does.

The errors themselves are fixed in #21880. This PR is stacked on #21880 so its CI stays green for review; once #21880 merges it retargets to master. On master alone, this change would turn both lint jobs red until #21880 lands.

Other plugins with the same gap

To find them, I ran mypy over metadata-ingestion with ignore_missing_imports = no in the [dev] venv and kept the imports that do not resolve. Then I installed each candidate's SDK and re-ran the normal lint to count the errors it uncovers on master:

Plugin / SDKHidden errors todayInstalled sizeIn this PR
azure-data-factory (azure-mgmt-datafactory)85~5 MByes
debug-recording (vcrpy, pyzipper, responses)0<1 MByes (cheap)
montecarlo (pycarlo)0~15 MByes (cheap)
db2 (ibm_db_sa)0~120 MB (bundles the IBM CLI driver)no
onnx-embeddings (onnxruntime, tokenizers)0~60 MBno
sso (playwright)0large (bundled driver)no
memray (debug requirement)0~22 MBno
sqlmeshn/an/ano: listed in CIRCULAR_EXTRAS, cannot coexist in the lock

debug-recording and montecarlo are clean today, but their sources import their SDKs in several places, so they are added to stop the next error from hiding. The heavy ones touch one import each and are left out.

Not fixable through extras (left as is): optional imports that no extra declares (pgvector, requests_kerberos, sqllineage, google.cloud.datacatalog_lineage, black), JPype's java.util in kafka_connect, and helper scripts or integration-test setup files (pyspark, pyflink, pydeequ, pydot).

CI time cost

  • python-lint: the extra packages add ~55 MB to a cold uv cache and well under 5 s to the install (one uv pip install with a warm cache finishes in under a second). mypy with no cache took 156–165 s with the new SDKs and 156–181 s without (two runs each), so the difference is within run-to-run noise. The uv cache key already hashes setup.py/uv.lock, so the ci-cache-warmup.yml entry picks the new packages up on the next push to master.
  • smoke-test-lint: codegen now runs before lint. From a fresh worktree, ./gradlew :metadata-ingestion:codegen took 18 s with the Gradle build cache and 36 s with --no-build-cache. That covers the mxe-schemas build, a base metadata-ingestion venv and the codegen script. Expect roughly 30–60 s more on a CI runner. The job already sets up Java and Gradle caching through setup-toolchain.

Failing before, passing after

All runs use the Gradle tasks CI runs, on this branch (with the [dev] venv rebuilt from scratch):

  • ./gradlew :metadata-ingestion:lint with this PR's dependencies:
    • with master's adf_probe.py and test_adf_source.py: fails, 85 errors (3 in adf_probe.py, 82 in test_adf_source.py)
    • with #21880's versions: Success: no issues found in 3802 source files
  • ./gradlew :smoke-test:pythonLint (now runs codegen first):
    • with master's test_okf_reimport.py: fails, test_okf_reimport.py:127 and :128, "DictWrapper" has no attribute "attribution" [attr-defined]
    • with #21880's version: Success: no issues found in 373 source files
    • the same master file with the generated schema_classes removed (what CI had before): Success, the gap this PR closes

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
  • Links to related issues (if applicable): stacked on #21880
  • Tests for the changes have been added/updated (if applicable): n/a, CI configuration
  • Docs related to the changes have been added/updated (if applicable): n/a
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes: n/a

šŸ¤– Opened with cclaude on behalf of @shirshanka