Skip to content

refactor!: make Configuration immutable - #2555

Merged
vdusek merged 2 commits into
v2from
refactor/immutable-configuration
Dec 1, 2026
Merged

vdusek merged 2 commits into
v2from
refactor/immutable-configuration

Conversation

@vdusek

@vdusek vdusek commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Sets frozen=True on Configuration, so assigning to a setting raises a ValidationError. To change a setting, pass it to the constructor. Type checkers also report the assignment, because the fields become read-only. This matches Crawlee JS v4.

The three doc examples that set configuration.purge_on_start = False now pass Configuration(purge_on_start=False) to service_locator.set_configuration(). The v2 upgrading guide has a new section on the change.

apify-sdk-python pins crawlee<2.0, so it is not affected yet. When it moves to v2, two places in src/apify/_configuration.py need a change: the disable_browser_sandbox_on_platform validator and the setattr loop in from_configuration. The SDK tests that assign to Actor.configuration need updates too.

Closes: #2549

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 30, 2026
@vdusek vdusek self-assigned this Nov 30, 2026
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v2@8b5f355). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff          @@
##             v2    #2555   +/-   ##
=====================================
  Coverage      ?   95.59%           
=====================================
  Files         ?      196           
  Lines         ?    15552           
  Branches      ?        0           
=====================================
  Hits          ?    14867           
  Misses        ?      685           
  Partials      ?        0           
Flag Coverage Δ
integration 75.57% <100.00%> (?)
unit 89.84% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

BREAKING CHANGE: `Configuration` instances are frozen. Assigning to a setting raises a `ValidationError`. Pass the value to the constructor or use `model_copy(update=...)`.
@vdusek
vdusek force-pushed the refactor/immutable-configuration branch from b2404cf to e5e4c9c Compare November 30, 2026 20:52
@vdusek
vdusek changed the base branch from master to v2 November 30, 2026 20:52
@vdusek
vdusek requested a review from Mantisus November 30, 2026 21:57
@vdusek
vdusek marked this pull request as ready for review November 30, 2026 21:57

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@apify-approval-mirror apify-approval-mirror Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mirroring approval from @Mantisus.

@vdusek
vdusek merged commit 3b92d08 into v2 Dec 1, 2026
46 checks passed
@vdusek
vdusek deleted the refactor/immutable-configuration branch December 1, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make Configuration immutable

2 participants