Skip to content

Guard type aliases and remove redundant imports in the postgres hook#61554

Merged
shahar1 merged 1 commit intoapache:mainfrom
Dev-iL:2602/postgres_types
Feb 7, 2026
Merged

Guard type aliases and remove redundant imports in the postgres hook#61554
shahar1 merged 1 commit intoapache:mainfrom
Dev-iL:2602/postgres_types

Conversation

@Dev-iL
Copy link
Collaborator

@Dev-iL Dev-iL commented Feb 6, 2026

This attempts to fix the below issue with doc generation in the google provider observed in CI that happens while importing the postgres provider.

Traceback (most recent call last):
  File 
  "/usr/python/lib/python3.10/site-packages/sphinx/ext/autodoc/importer.py", line 143, in import_module
    return importlib.import_module(modname)
  File "/usr/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return 
  _bootstrap._gcd_import(name, package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in 
  _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 
  File "/opt/airflow/providers/google/src/airflow/providers/google/cloud/transfers/bigquery_to_postgres.py", line 31, in <module>
    from airflow.providers.postgres.hooks.postgres import PostgresHook
  File 
  "/opt/airflow/providers/postgres/src/airflow/providers/postgres/hooks/postgres.py", line 68, in <module>
    CursorType: TypeAlias = DictCursor | RealDictCursor | NamedTupleCursor
TypeError: unsupported operand type(s) for |: 'DictCursor' and 'RealDictCursor'

The fix is moving the two TypeAlias definitions into the existing TYPE_CHECKING block. Also, imports were cleaned up a bit.

related: #61532


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@Dev-iL Dev-iL force-pushed the 2602/postgres_types branch from 70bd604 to de2d4a0 Compare February 6, 2026 21:01
Copy link
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI looks green, thanks @Dev-iL !

@shahar1 shahar1 changed the title Guard type aliases & remove redundant imports in the postgres hook Guard type aliases and remove redundant imports in the postgres hook Feb 7, 2026
@shahar1 shahar1 merged commit 19c17c4 into apache:main Feb 7, 2026
90 checks passed
jhgoebbert pushed a commit to jhgoebbert/airflow_Owen-CH-Leung that referenced this pull request Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants