Skip to content

refactor(init): replace self.config.settings with DEFAULT_SETTINGS - #1832

Open
bearomorphism wants to merge 1 commit into
masterfrom
default-settings-init
Open

refactor(init): replace self.config.settings with DEFAULT_SETTINGS#1832
bearomorphism wants to merge 1 commit into
masterfrom
default-settings-init

Conversation

@bearomorphism

@bearomorphism bearomorphism commented Jan 31, 2026

Copy link
Copy Markdown
Collaborator

Related to #1831

In usual use cases, self.config.settings is a copy of DEFAULT_SETTINGS

This probably makes more sense. wdyt

@codecov

codecov Bot commented Jan 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (4b93a50) to head (78956b5).
⚠️ Report is 87 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1832   +/-   ##
=======================================
  Coverage   98.23%   98.23%           
=======================================
  Files          61       61           
  Lines        2779     2779           
=======================================
  Hits         2730     2730           
  Misses         49       49           

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

@bearomorphism
bearomorphism changed the base branch from next-release to master February 1, 2026 11:00
@Lee-W

Lee-W commented Feb 2, 2026

Copy link
Copy Markdown
Member

conflict. convert it to draft

@bearomorphism
bearomorphism marked this pull request as draft February 2, 2026 02:24

@Manny7717 Manny7717 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.

Verified behavior-preserving refactor (head 78956b5):

  1. get_version_scheme(DEFAULT_SETTINGS, version_scheme)version_scheme is always passed explicitly from _ask_version_scheme() (a questionary.select over KNOWN_SCHEMES), so the settings argument is only consulted for the deprecated version_type fallback when name is None — unreachable here. No behavior change.
  2. encoding=DEFAULT_SETTINGS["encoding"] (write + read of .pre-commit-config.yaml) — Init.__call__ early-returns when self.config.path exists (init.py:88-90), so the only reachable path has config.settings == a DEFAULT_SETTINGS.copy() (base_config.py:20, no config data loaded). Identical values, same behavior. This also removes the latent coupling to whatever a future config-loading path might inject.
  • tests/commands/test_init_command.py: 30/30 pass on head.
  • CI matrix green (python-check 3.10-3.14 × 3 OS, check-links, codecov).

Agreed this is the right direction for #1831. One non-blocking note for a follow-up: the remaining self.config uses in init.py (e.g. self.config.settings in _get_config_data's fallback and self.cz) could get the same treatment once #1831's discussion settles on the full scope.

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