potiuk commented on code in PR #54258: URL: https://github.com/apache/airflow/pull/54258#discussion_r2280378222
########## contributing-docs/08_static_code_checks.rst: ########## @@ -579,118 +302,48 @@ command (example for ``airflow`` files): .. code-block:: bash - pre-commit run --hook-stage manual mypy-<FOLDER> --all-files + prek --hook-stage manual mypy-<FOLDER> --all-files For example: .. code-block:: bash - pre-commit run --hook-stage manual mypy-airflow --all-files + prek --hook-stage manual mypy-airflow --all-files To show unused mypy ignores for any providers/airflow etc, eg: run below command: .. code-block:: bash export SHOW_UNUSED_MYPY_WARNINGS=true - pre-commit run --hook-stage manual mypy-airflow --all-files + prek --hook-stage manual mypy-airflow --all-files MyPy uses a separate docker-volume (called ``mypy-cache-volume``) that keeps the cache of last MyPy execution in order to speed MyPy checks up (sometimes by order of magnitude). While in most cases MyPy will handle refreshing the cache when and if needed, there are some cases when it won't (cache invalidation is the hard problem in computer science). This might happen for example when we upgrade MyPY. In such cases you might need to manually remove the cache volume by running ``breeze down --cleanup-mypy-cache``. -Running static code checks via Breeze -------------------------------------- - -The static code checks can be launched using the Breeze environment. - -You run the static code checks via ``breeze static-check`` or commands. - -You can see the list of available static checks either via ``--help`` flag or by using the autocomplete -option. - -Run the ``mypy`` check for the currently staged changes (in ``airflow/`` excluding providers): - -.. code-block:: bash - - breeze static-checks --type mypy-airflow - -Run the ``mypy`` check for all files: - -.. code-block:: bash - - breeze static-checks --type mypy-airflow --all-files - -Run the ``ruff`` check for the ``tests/core.py`` file with verbose output: - -.. code-block:: bash - - breeze static-checks --type ruff --file tests/core.py --verbose - -Run the ``ruff`` check for the ``tests.core`` package with verbose output: - -.. code-block:: bash - - breeze static-checks --type ruff --file tests/core/* --verbose - -Run the ``ruff-format`` check for the files ``airflow/example_dags/example_bash_operator.py`` and -``airflow/example_dags/example_python_operator.py``: - -.. code-block:: bash - - breeze static-checks --type ruff-format --file airflow/example_dags/example_bash_operator.py \ - airflow/example_dags/example_python_operator.py - -Run all checks for the currently staged files: - -.. code-block:: bash - - breeze static-checks - -Run all checks for all files: - -.. code-block:: bash - - breeze static-checks --all-files - -Run all checks for last commit: - -.. code-block:: bash - - breeze static-checks --last-commit - -Run all checks for all changes in my branch since branched from main: - -.. code-block:: bash - - breeze static-checks --type mypy-airflow --only-my-changes - -More examples can be found in -`Breeze documentation <../dev/breeze/doc/03_developer_tasks.rst#running-static-checks>`_ - - -Debugging pre-commit check scripts requiring image +Debugging prek check scripts requiring image -------------------------------------------------- Those commits that use Breeze docker image might sometimes fail, depending on your operating system and docker setup, so sometimes it might be required to run debugging with the commands. This is done via two environment variables ``VERBOSE`` and ``DRY_RUN``. Setting them to "true" will respectively show the commands to run before running them or skip running the commands. -Note that you need to run pre-commit with --verbose command to get the output regardless of the status +Note that you need to run prek with --verbose command to get the output regardless of the status of the static check (normally it will only show output on failure). Printing the commands while executing: .. code-block:: bash - VERBOSE="true" pre-commit run --verbose ruff + VERBOSE="true" prek --verbose ruff Just performing dry run: .. code-block:: bash - DRY_RUN="true" pre-commit run --verbose ruff + DRY_RUN="true" prek --verbose ruff Review Comment: Yes - they are breeze-specific variables. This is quite "deep" and already largely not-needed chapter. I removed it entirely. -- 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]
