Skip to content

Conversation

@meek2100
Copy link

@meek2100 meek2100 commented Nov 4, 2025

This pull request introduces the --config <path> command-line option, allowing users to explicitly define the path to their TOML configuration file, overriding the default recursive search for .mdformat.toml.

This feature primarily supports integration with modern tooling like pre-commit hooks and centralized configuration management systems where config files may live outside the project root or in a custom directory.

Key Changes:

  1. New CLI Argument: Added --config (type Path) to src/mdformat/_cli.py.
  2. Config Logic: Implemented read_single_config_file in src/mdformat/_conf.py to support direct path loading. The run function logic prioritizes --config and correctly handles non-existent file paths by exiting with an error.
  3. Tests: Added a new test case (test_config_override_precedence) verifying that the explicit --config correctly overrides auto-detected .mdformat.toml settings.
  4. Documentation: Updated docs/users/configuration_file.md to document the new usage.
  5. Code Quality Fix: Corrected the InvalidPath exception class in src/mdformat/_cli.py to properly call super().__init__(path), resolving the flake8-bugbear (B042) warning.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant