Anuragp22 opened a new pull request, #67522:
URL: https://github.com/apache/airflow/pull/67522

   Lazy-load `neo4j` SDK imports to reduce memory footprint and import time of 
`airflow.providers.neo4j.hooks.neo4j`, following the same pattern as #62365 
(snowflake) and #67519 (elasticsearch).
   
   ### Hook changes
   - Removed the top-level `from neo4j import Driver, GraphDatabase`.
   - `Driver` is only used as a type annotation, so it now lives under `if 
TYPE_CHECKING:`.
   - `GraphDatabase.driver(...)` is only invoked inside `_create_driver`, so 
the import is moved into that method body.
   
   ### Test changes
   - Updated five `mock.patch` targets in `test_neo4j.py` from 
`airflow.providers.neo4j.hooks.neo4j.GraphDatabase` to `neo4j.GraphDatabase` 
(and `...GraphDatabase.driver` for the parametrized test), since 
`GraphDatabase` is no longer a module-level symbol in the hook module.
   
   ### Validation
   Local smoke check (Windows host; full unit suite requires the Linux-only 
`fcntl` import that Airflow's test conftest pulls in transitively):
   
   - Importing `Neo4jHook` no longer loads the `neo4j` package into 
`sys.modules`.
   - `Driver` and `GraphDatabase` are no longer attributes of the hook module.
   - `neo4j.GraphDatabase` and `neo4j.GraphDatabase.driver` resolve as 
`mock.patch` targets.
   
   The unit tests in `providers/neo4j/tests/unit/neo4j/hooks/test_neo4j.py` 
should now pass against the moved import; CI will be the source of truth here.
   
   * related: #67515
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes — Claude (Opus) was used for the mechanical edits and the 
announcement comment on #67515. Reviewed by hand against the pattern in #62365 
and #67519.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to