MCPcopy Index your code
hub / github.com/python/mypy / replacement_checkers

Method replacement_checkers

mypy/checkstrformat.py:874–898  ·  view source on GitHub ↗

Returns a list of tuples of two functions that check whether a replacement is of the right type for the specifier. The first function takes a node and checks its type in the right type context. The second function just checks a type.

(
        self, specifier: ConversionSpecifier, context: Context, expr: FormatStringExpr
    )

Source from the content-addressed store, hash-verified

872 return checkers
873
874 def replacement_checkers(
875 self, specifier: ConversionSpecifier, context: Context, expr: FormatStringExpr
876 ) -> list[Checkers] | None:
877 """Returns a list of tuples of two functions that check whether a replacement is
878 of the right type for the specifier. The first function takes a node and checks
879 its type in the right type context. The second function just checks a type.
880 """
881 checkers: list[Checkers] = []
882
883 if specifier.width == "*":
884 checkers.append(self.checkers_for_star(context))
885 if specifier.precision == "*":
886 checkers.append(self.checkers_for_star(context))
887
888 if specifier.conv_type == "c":
889 c = self.checkers_for_c_type(specifier.conv_type, context, expr)
890 if c is None:
891 return None
892 checkers.append(c)
893 elif specifier.conv_type is not None and specifier.conv_type != "%":
894 c = self.checkers_for_regular_type(specifier.conv_type, context, expr)
895 if c is None:
896 return None
897 checkers.append(c)
898 return checkers
899
900 def checkers_for_star(self, context: Context) -> Checkers:
901 """Returns a tuple of check functions that check whether, respectively,

Callers 1

Calls 4

checkers_for_starMethod · 0.95
checkers_for_c_typeMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected