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

Method columns

crates/ruff_python_formatter/src/string/docstring.rs:1716–1728  ·  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

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

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

no outgoing calls

Tested by

no test coverage detected