How to use the flynt.format.QuoteTypes.all function in flynt

To help you get started, we’ve selected a few flynt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ikamensh / flynt / test / test_styles.py View on Github external
@pytest.mark.parametrize(argnames="quote_type", argvalues=QuoteTypes.all)
def test_initial_doesnt_matter(quote_type):
    code = random.choice(["'abra'", '"bobro"', "'''abra'''", '"""bobro"""'])
    assert get_quote_type(set_quote_type(code, quote_type)) == quote_type
github ikamensh / flynt / src / flynt / lexer / PyToken.py View on Github external
def get_quote_type(self):
        assert self.toknum is token.STRING
        for qt in QuoteTypes.all:
            if self.tokval[: len(qt)] == qt and self.tokval[-len(qt) :] == qt:
                return qt

        if self.is_legacy_unicode_string():
            for qt in QuoteTypes.all:
                if self.tokval[1 : len(qt) + 1] == qt and self.tokval[-len(qt) :] == qt:
                    return qt

        raise FlyntException(f"Can't determine quote type of the string {self.tokval}.")
github ikamensh / flynt / src / flynt / lexer / PyToken.py View on Github external
def get_quote_type(self):
        assert self.toknum is token.STRING
        for qt in QuoteTypes.all:
            if self.tokval[: len(qt)] == qt and self.tokval[-len(qt) :] == qt:
                return qt

        if self.is_legacy_unicode_string():
            for qt in QuoteTypes.all:
                if self.tokval[1 : len(qt) + 1] == qt and self.tokval[-len(qt) :] == qt:
                    return qt

        raise FlyntException(f"Can't determine quote type of the string {self.tokval}.")