potiuk commented on code in PR #58825:
URL: https://github.com/apache/airflow/pull/58825#discussion_r2578436832
##########
shared/import_utils/src/airflow_shared/import_utils/module_loading.py:
##########
@@ -67,3 +67,25 @@ def qualname(o: object | Callable) -> str:
def iter_namespace(ns: ModuleType):
return pkgutil.iter_modules(ns.__path__, ns.__name__ + ".")
+
+
+def is_valid_dotpath(path: str) -> bool:
Review Comment:
I see the point. I don't think we should **actively** create many utils, but
when we already have mostly copied code, I think it's definitely worth it -
even if it's a small code.
We have a lot of protection already that even if someone gets confused
initially, either the pytest tests, or prek hook will fail if wrong import is
used. For example if there will be a distribution when somene imports from
`airflow._shared` - the pytests run in CI will fail. Whe you run `uv sync` in
`task-sdk` code for example (once we complete the isolation) will **NOT** have
`airflow._shared` in PYTHONPATH - because the distribution with that code will
not be in `pyproject.toml` and:
```bash
cd task-sdk
uv run pytest
```
will fail.
Plus we will add all the prek hooks and checks to provide very detailed
explanation of why certain bad imports are wrong and how to fix them. Which is
also a great self-learning exercise, because people will be explained or have
to learn how things work as part of this.
I think it's worth it, especially that `shared` projects concept is here to
stay and people will have to get used to it anyway - one more or less library
following exactly the same pattern - and one that is easy usable - has at most
opportunity to let people learn the patterns more quickly and easily.
--
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]