# yapf: disable does not preserve indent_width
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
`# yapf: disable` does not preserve the indent width of the code to not be formatted, and applies `indent_width` instead. For example, in a python file using an indent of two spaces, `yapf` outputs a file with an indent width of four spaces in the disabled region:
```python
# yapf_disable_indent_width_bug.py
# yapf: disable
def dont_indent_me():
return
# yapf: enable
```
```python
python -m yapf -i yapf_disable_indent_width_bug.py
```
```python
# yapf_disable_indent_width_bug.py
# yapf: disable
def dont_indent_me():
return
# yapf: enable
```
Aside from throwing an error, this is probably the least awful thing to do when there is other code that yapf needs to format. That said it probably warrants noting that `# yapf: disable` will be disregarded wrt indent widths in its [readme section](https://github.com/google/yapf#why-does-yapf-destroy-my-awesome-formatting).
Contributor guide
Assessment
This issue has not been assessed yet.