Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
403 changes: 141 additions & 262 deletions README.md

Large diffs are not rendered by default.

53 changes: 28 additions & 25 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ Changelog = "https://github.com/grahamcracker1234/dedent/releases"

[dependency-groups]
dev = [
"basedpyright>=1.37.1",
"pytest>=9.0.2",
"pytest-cov>=7.0.0",
"ruff>=0.14.11",
"syrupy>=5.1.0",
"basedpyright>=1.39.10",
"inline-snapshot>=0.35.4",
"pytest>=9.1.1",
"pytest-cov>=7.1.0",
"ruff>=0.16.3",
]

[build-system]
Expand Down Expand Up @@ -100,22 +100,22 @@ docstring-code-format = true

[tool.ruff.lint]
ignore = [
"D203", # Conflicts with D211
"D212", # Conflicts with D213
"SLF001", # Conflicts with basedpyright[reportPrivateUsage]
"incorrect-blank-line-before-class", # Conflicts with D211
"multi-line-summary-first-line", # Conflicts with D213
"private-member-access", # Conflicts with basedpyright[reportPrivateUsage]
# Formatter conflicting rules
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"tab-indentation",
"indentation-with-invalid-multiple",
"indentation-with-invalid-multiple-comment",
"over-indented",
"docstring-tab-indentation",
"triple-single-quotes",
"bad-quotes-inline-string",
"bad-quotes-multiline-string",
"bad-quotes-docstring",
"avoidable-escaped-quote",
"missing-trailing-comma",
"prohibited-trailing-comma",
]
select = [
"FAST", # FastAPI
Expand Down Expand Up @@ -186,11 +186,11 @@ convention = "pep257"
[tool.ruff.lint.per-file-ignores]
"*.py" = ["PYI"]
"**/tests/**/*.py" = [
"S101", # assert
"PLR2004", # magic-value-comparison
"INP", # flake8-no-pep420 (implicit-namespace-package)
"D", # pydocstyle
"DOC", # pydoclint
"assert",
"magic-value-comparison",
"INP", # flake8-no-pep420 (implicit-namespace-package)
"D", # pydocstyle
"DOC", # pydoclint
]
"**/scripts/*.py" = [
"INP", # flake8-no-pep420 (implicit-namespace-package)
Expand All @@ -202,3 +202,6 @@ convention = "pep257"
[tool.pytest.ini_options]
pythonpath = ["src"]
addopts = ["--import-mode=importlib"]

[tool.inline-snapshot]
format-command = "ruff format --stdin-filename {filename}"
12 changes: 6 additions & 6 deletions src/dedent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
A library for dedenting text with support for interpolated values.

This module provides a `dedent` function that removes common leading whitespace from
multiline strings, similar to `textwrap.dedent` but with automatic smart stripping and
multiline-value alignment. Works with Python 3.10+.
multiline strings, follows PEP 822's newline behavior, and aligns multiline values.
Works with Python 3.10+.

Key features:

- Removes minimum common indentation from all lines
- Smart-strips leading/trailing whitespace by default
- Aligns multiline interpolated values to match surrounding indentation
- On Python 3.14+: t-strings with per-value format spec directives (`{value:align}`)
- Uses PEP 822's exact common-prefix and closing-line indentation rules
- Omits the opening newline and preserves all other whitespace
- Aligns multiline interpolated values to their interpolation column
- On Python 3.14+: t-strings with per-value alignment opt-out (`{value:noalign}`)
- On Python 3.10-3.13: f-strings with the `align` wrapper
"""

Expand Down
Loading
Loading