bhavaniravi opened a new issue, #26984:
URL: https://github.com/apache/airflow/issues/26984
### Apache Airflow version
main (development)
### What happened
Running pre-commit without installing breeze errors out
```
Traceback (most recent call last):
File
"/Users/bhavaniravi/projects/airflow/./scripts/ci/pre_commit/pre_commit_flake8.py",
line 39, in <module>
from airflow_breeze.global_constants import MOUNT_SELECTED
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/global_constants.py",
line 30, in <module>
from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 240, in <module>
AIRFLOW_SOURCES_ROOT =
find_airflow_sources_root_to_operate_on().resolve()
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 235, in find_airflow_sources_root_to_operate_on
reinstall_if_setup_changed()
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 148, in reinstall_if_setup_changed
if sources_hash != package_hash:
UnboundLocalError: local variable 'package_hash' referenced before assignment
```
And to understand the error better, I commented out the exception handling
code.
```
try:
package_hash = get_package_setup_metadata_hash()
except ModuleNotFoundError as e:
if "importlib_metadata" in e.msg:
return False
```
It returned
```
Traceback (most recent call last):
File
"/Users/bhavaniravi/projects/airflow/./scripts/ci/pre_commit/pre_commit_flake8.py",
line 39, in <module>
from airflow_breeze.global_constants import MOUNT_SELECTED
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/global_constants.py",
line 30, in <module>
from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 240, in <module>
AIRFLOW_SOURCES_ROOT =
find_airflow_sources_root_to_operate_on().resolve()
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 235, in find_airflow_sources_root_to_operate_on
reinstall_if_setup_changed()
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 141, in reinstall_if_setup_changed
package_hash = get_package_setup_metadata_hash()
File
"/Users/bhavaniravi/projects/airflow/dev/breeze/src/airflow_breeze/utils/path_utils.py",
line 86, in get_package_setup_metadata_hash
for line in
distribution('apache-airflow-breeze').metadata.as_string().splitlines(keepends=False):
File
"/opt/homebrew/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py",
line 524, in distribution
return Distribution.from_name(distribution_name)
File
"/opt/homebrew/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py",
line 187, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: apache-airflow-breeze
```
### What you think should happen instead
The error should be handled gracefully, and print out the command to install
breeze
### How to reproduce
_No response_
### Operating System
MacOS Monetary
### Versions of Apache Airflow Providers
_No response_
### Deployment
Virtualenv installation
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
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]