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

   While working on this https://github.com/apache/airflow/pull/43243, I was 
following 
https://github.com/apache/airflow/blob/main/contributing-docs/13_metadata_database_updates.rst
 and I ran into an error with  pre-commit hook.
   
   When running the revision command as follows:
   
   ```
   root@f1f78138ad78:/opt/airflow/airflow# alembic revision -m "New revision"
     Generating 
/opt/airflow/airflow/migrations/versions/01b38be821e9_new_revision.py ...  done
   ```
   
   It creates a file as follows:
   
   ```python
   """New revision
   
   Revision ID: cd7be1ae8b80
   Revises: 05234396c6fc
   Create Date: 2024-10-22 01:44:17.873864
   
   """
   
   import sqlalchemy as sa
   from alembic import op
   
   # revision identifiers, used by Alembic.
   revision = 'cd7be1ae8b80'
   down_revision = '05234396c6fc'
   branch_labels = None
   depends_on = None
   ```
   
   Notice single quotes in `revision` & `down_revision`.
   
   Now if I just run that single pre-commit hook 
(`update-migration-references`), it fails
   
   ```
   ❯ pre-commit run "update-migration-references" --all-files
   Update migration ref 
doc.................................................Failed
   - hook id: update-migration-references
   - exit code: 1
   
   Using 'uv' to install Airflow
   
   Using airflow version from current sources
   
   Updating migration reference for airflow
   Making sure airflow version updated
   Making sure there's no mismatching revision numbers
   Traceback (most recent call last):
     File "/opt/airflow/scripts/in_container/run_migration_reference.py", line 
246, in <module>
       correct_mismatching_revision_nums(revisions=revisions)
     File "/opt/airflow/scripts/in_container/run_migration_reference.py", line 
230, in correct_mismatching_revision_nums
       new_content = content.replace(revision_id_match.group(1), 
revision_match.group(1), 1)
   AttributeError: 'NoneType' object has no attribute 'group'
   Error 1 returned
   
   If you see strange stacktraces above, run `breeze ci-image build --python 
3.9` and try again.
   ```
   
   That isn't a problem generally as `ruff` will fail before and convert it 
into double quotes. But rather than doing that, we fix it at source.
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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