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

   I hit this in airflow-core/src/airflow/utils/helpers.py, line 142. One line 
did all the work: return CAMELCASE_TO_SNAKE_CASE_REGEX.sub(r"_\1", 
camel_str).lower(). The pattern was (?!^)([A-Z]+), which splits any uppercase 
run starting after character 1.
   
   It doesn't handle acronyms. HTTPServer became h_ttpserver. XMLHttpRequest 
became x_mlhttp_request. That isn't right.
   
   I've swapped in 2 passes. First ([A-Z]+)([A-Z][a-z]) puts a boundary between 
an acronym and the next word. Then ([a-z\d])([A-Z]) picks up the usual 
lower-to-upper boundary. Two regexes, not one.
   
   LocalTaskJob still gives local_task_job. somethingVeryRandom still gives 
something_very_random. Those 2 original cases plus 2 new acronym assertions 
pass in airflow-core/tests/unit/utils/test_helpers_camel_case.py. I've kept the 
change to that 1 function and its regex constants.
   
   I ran pytest on the new file: 2 passed. ruff check and ruff format --check 
on both files came back clean.
   


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

  • [PR] Fix convert_camel_to_snak... adityajai119 (via GitHub) via commits

Reply via email to