MCPcopy Create free account
hub / github.com/astral-sh/ruff / columns

Method columns

crates/ruff_python_formatter/src/string/docstring.rs:1713–1725  ·  view source on GitHub ↗

Returns the indentation's visual width in columns/spaces. For docstring indentation, black counts spaces as 1 and tabs by increasing the indentation up to the next multiple of 8. This is effectively a port of [`str.expandtabs`](https://docs.python.org/3/library/stdtypes.html#str.expandtabs), which black [calls with the default tab width of 8](https://github.com/psf/black/blob/c36e468794f9256d5e92

(self)

Source from the content-addressed store, hash-verified

1711 /// [`str.expandtabs`](https://docs.python.org/3/library/stdtypes.html#str.expandtabs),
1712 /// which black [calls with the default tab width of 8](https://github.com/psf/black/blob/c36e468794f9256d5e922c399240d49782ba04f1/src/black/strings.py#L61).
1713 const fn columns(self) -> usize {
1714 match self {
1715 Self::Spaces(count) => count,
1716 Self::Tabs(count) => count * Self::TAB_INDENT_WIDTH,
1717 Self::TabSpaces { tabs, spaces } => tabs * Self::TAB_INDENT_WIDTH + spaces,
1718 Self::SpacesTabs { spaces, tabs } => {
1719 let mut indent = spaces;
1720 indent += tab_offset(indent, Self::TAB_INDENT_WIDTH);
1721 indent + (tabs - 1) * Self::TAB_INDENT_WIDTH
1722 }
1723 Self::Mixed { width, .. } => width,
1724 }
1725 }
1726
1727 /// Returns the length of the indentation in bytes.
1728 ///

Callers 7

formatFunction · 0.80
run_action_queueMethod · 0.80
print_oneMethod · 0.80
formatMethod · 0.80
trim_start_strMethod · 0.80
partial_cmpMethod · 0.80
eqMethod · 0.80

Calls 1

tab_offsetFunction · 0.85

Tested by

no test coverage detected