MCPcopy
hub / github.com/psf/black / _should_process_fmt_comment

Function _should_process_fmt_comment

src/black/comments.py:201–218  ·  view source on GitHub ↗

Check if comment should be processed for fmt handling. Returns (should_process, is_fmt_off, is_fmt_skip).

(
    comment: ProtoComment, leaf: Leaf
)

Source from the content-addressed store, hash-verified

199
200
201def _should_process_fmt_comment(
202 comment: ProtoComment, leaf: Leaf
203) -> tuple[bool, bool, bool]:
204 """Check if comment should be processed for fmt handling.
205
206 Returns (should_process, is_fmt_off, is_fmt_skip).
207 """
208 is_fmt_off = contains_fmt_directive(comment.value, FMT_OFF)
209 is_fmt_skip = contains_fmt_directive(comment.value, FMT_SKIP)
210
211 if not is_fmt_off and not is_fmt_skip:
212 return False, False, False
213
214 # Invalid use when `# fmt: off` is applied before a closing bracket
215 if is_fmt_off and leaf.type in CLOSING_BRACKETS:
216 return False, False, False
217
218 return True, is_fmt_off, is_fmt_skip
219
220
221def _is_valid_standalone_fmt_comment(

Callers 1

convert_one_fmt_off_pairFunction · 0.85

Calls 1

contains_fmt_directiveFunction · 0.85

Tested by

no test coverage detected