MCPcopy Index your code
hub / github.com/ipython/ipython / has_open_quotes

Function has_open_quotes

IPython/core/completer.py:339–357  ·  view source on GitHub ↗

Return whether a string has open quotes. This simply counts whether the number of quote characters of either type in the string is odd. Returns ------- If there is an open quote, the quote character is returned. Else, return False.

(s: str)

Source from the content-addressed store, hash-verified

337
338
339def has_open_quotes(s: str) -> Union[str, bool]:
340 """Return whether a string has open quotes.
341
342 This simply counts whether the number of quote characters of either type in
343 the string is odd.
344
345 Returns
346 -------
347 If there is an open quote, the quote character is returned. Else, return
348 False.
349 """
350 # We check " first, then ', so complex cases with nested quotes will get
351 # the " to take precedence.
352 if s.count('"') % 2:
353 return '"'
354 elif s.count("'") % 2:
355 return "'"
356 else:
357 return False
358
359
360def protect_filename(s: str, protectables: str = PROTECTABLES) -> str:

Callers 1

file_matcherMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…