Skip to content

Conversation

@amoghrajesh
Copy link
Contributor

@amoghrajesh amoghrajesh commented Oct 27, 2025

Structlog released 25.5.0 version where structlog.dev.Styles was renamed as structlog.dev.ColumnStyles along with some refactoring. This breaks our CI like this:

  Stderr: Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/__init__.py", line 81, in <module>
      settings.initialize()
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/settings.py", line 698, in initialize
      LOGGING_CLASS_PATH = configure_logging()
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/logging_config.py", line 88, in configure_logging
      from airflow._shared.logging import configure_logging, init_log_folder, translate_config_values
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/_shared/logging/__init__.py", line 27, in <module>
      from .structlog import configure_logging, init_log_file, init_log_folder
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/_shared/logging/structlog.py", line 38, in <module>
      from .percent_formatter import PercentFormatRender
    File "/home/runner/work/airflow/airflow/airflow-core/src/airflow/_shared/logging/percent_formatter.py", line 29, in <module>
      from structlog.dev import ConsoleRenderer, Styles
  ImportError: cannot import name 'Styles' from 'structlog.dev' (/home/runner/work/airflow/airflow/.venv/lib/python3.10/site-packages/structlog/dev.py)

Move structlog imports into a TYPE_CHECKING block to untie version bumps


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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 airflow-core/newsfragments.

Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets see if TP's idea works

@amoghrajesh
Copy link
Contributor Author

Just tried it 14be76e

@uranusjr
Copy link
Member

We should remove the version bumps too.

@amoghrajesh
Copy link
Contributor Author

Fair point, pushing a fix

@amoghrajesh amoghrajesh changed the title Bump structlog to 25.5.0 and handle updates to code Move structlog imports into a TYPE_CHECKING block to untie version bumps Oct 27, 2025
@amoghrajesh
Copy link
Contributor Author

That worked, thanks @uranusjr

@amoghrajesh
Copy link
Contributor Author

Failing test is unrelated

@amoghrajesh amoghrajesh merged commit 08c317d into apache:main Oct 27, 2025
87 of 88 checks passed
kaxil pushed a commit that referenced this pull request Oct 27, 2025
@pankajkoti
Copy link
Member

Thanks for the fix @amoghrajesh.

@kaxil wish to check if this would be included in 3.1.2 (not sure if we're still planning to cut one before you go on leave :))? Today, I observed with my local development efforts that upon installing Cosmos on 3.1.1 as base image, somehow structlog version gets updated (maybe via some cosmos dependency), and I observe this failure. I verified that Airflow 3.1.1 installs structlog 25.4.0, so I believe it's safe by itself.

@kaxil kaxil added this to the Airflow 3.1.2 milestone Oct 27, 2025
@kaxil
Copy link
Member

kaxil commented Oct 27, 2025

Yup, this will be part of 3.1.2. Has been chery-picked already to v3-1-test

@hynek
Copy link

hynek commented Oct 29, 2025

Wow so sorry for that! To add some context from the structlog side: Styles wasn't really a thing – it was a hack to make the old-style class-variables-as-storage work as a type hint (I mean, what does Union[_Styles, Type[_Styles]] even mean). And since it was never documented, I kinda treated it like an internal thing.

Since you've already fixed it, I don't think it makes any sense to do any emergency releases form my side. Again, I'm sorry.

@amoghrajesh
Copy link
Contributor Author

All good, @hynek!

I do not think any other project would've suffered it but we certainly did because Styles was exposed in the public interface, and we used it. IAC, we moved it rightly to a type checking block and I think we are good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants