How to use the pycodestyle.stdin_get_value function in pycodestyle

To help you get started, we’ve selected a few pycodestyle 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 Parallels / githooks / hooks.d / pycheck / pycodestyle / testsuite / test_shell.py View on Github external
def tearDown(self):
        sys.argv = self._saved_argv
        sys.stdout = self._saved_stdout
        sys.stderr = self._saved_stderr
        pycodestyle.PROJECT_CONFIG = self._saved_pconfig
        pycodestyle.RawConfigParser._read = self._saved_cpread
        pycodestyle.stdin_get_value = self._saved_stdin_get_value
github PyCQA / flake8-import-order / tests / test_stdlib.py View on Github external
def _checker(data):
    pycodestyle.stdin_get_value = lambda: data
    tree = ast.parse(data)
    checker = ImportOrderChecker(None, tree)
    checker.options = {}
    return checker
github PyCQA / flake8-import-order / tests / test_flake8_linter.py View on Github external
def test_linter():
    argv = ['--application-import-names=flake8_import_order']
    parser = pycodestyle.get_parser('', '')
    Linter.add_options(parser)
    options, args = parser.parse_args(argv)
    Linter.parse_options(options)

    data = 'import ast\nimport flake8_import_order\n'
    pycodestyle.stdin_get_value = lambda: data
    tree = ast.parse(data)
    checker = Linter(tree, None)
    for lineno, col_offset, msg, instance in checker.run():
        assert msg.startswith(
            'I201 Missing newline between import groups.',
        )
github flowroute / ebb-lint / ebb_lint / flake8.py View on Github external
def source(self):
        if self._source is None:
            if self.filename != 'stdin':
                self._source = read_file_using_source_encoding(self.filename)
            elif six.PY2:  # ✘py33 ✘py34 ✘py35
                # On python 2, reading from stdin gives you bytes, which must
                # be decoded.
                self._source = decode_string_using_source_encoding(
                    pycodestyle.stdin_get_value())
            else:  # ✘py27
                # On python 3, reading from stdin gives you text.
                self._source = pycodestyle.stdin_get_value()
        return self._source
github smarkets / flake8-strict / flake8_strict.py View on Github external
def _process_file(filename):
    if filename == 'stdin':
        code = pycodestyle.stdin_get_value()
    else:
        with open(filename, 'rb') as f:
            code = f.read().decode('utf-8')
    return _process_code(code)
github graphql-python / gql / gql-checker / gql_checker / __init__.py View on Github external
def load_file(self):
        if self.filename in ("stdin", "-", None):
            self.filename = "stdin"
            self.lines = pycodestyle.stdin_get_value().splitlines(True)
        else:
            self.lines = pycodestyle.readlines(self.filename)

        if not self.tree:
            self.tree = ast.parse("".join(self.lines))
github flowroute / ebb-lint / ebb_lint / flake8.py View on Github external
def source(self):
        if self._source is None:
            if self.filename != 'stdin':
                self._source = read_file_using_source_encoding(self.filename)
            elif six.PY2:  # ✘py33 ✘py34 ✘py35
                # On python 2, reading from stdin gives you bytes, which must
                # be decoded.
                self._source = decode_string_using_source_encoding(
                    pycodestyle.stdin_get_value())
            else:  # ✘py27
                # On python 3, reading from stdin gives you text.
                self._source = pycodestyle.stdin_get_value()
        return self._source
github PyCQA / flake8-import-order / flake8_import_order / checker.py View on Github external
def load_file(self):
        if self.filename in ("stdin", "-", None):
            self.filename = "stdin"
            self.lines = pycodestyle.stdin_get_value().splitlines(True)
        else:
            self.lines = pycodestyle.readlines(self.filename)

        if self.tree is None:
            self.tree = ast.parse(''.join(self.lines))