Пример #1
0
 def open(self) -> None:
     py_version = get_global_option(self, "py-version")
     self._py38_plus = py_version >= (3, 8)
     self._max_length: int = (
         self.config.max_line_length_suggestions
         or get_global_option(self, "max-line-length")
     )
Пример #2
0
    def test_ignore_paths_with_no_value(self) -> None:
        """Test ignore-paths option with no value.
        Compare against actual list to see if validator works.
        """
        options = get_global_option(self.checker, "ignore-paths")

        assert options == []
Пример #3
0
    def test_ignore_paths_with_no_value(self) -> None:
        """Test exclude-too-few-public-methods option with no value.
        Compare against actual list to see if validator works.
        """
        options = get_global_option(self.checker, "exclude-too-few-public-methods")

        assert options == []
Пример #4
0
    def test_exclude_too_few_methods_with_value(self) -> None:
        """Test exclude-too-few-public-methods option with value."""
        options = get_global_option(self.checker, "exclude-too-few-public-methods")

        assert any(i.match("toml") for i in options)
        assert any(i.match("toml.*") for i in options)
        assert any(i.match("toml.TomlEncoder") for i in options)
Пример #5
0
    def test_ignore_paths_with_value(self) -> None:
        """Test ignore-paths option with value"""
        options = get_global_option(self.checker, "ignore-paths")

        assert any(i.match("dir/tests/file.py") for i in options)
        assert any(i.match("dir\\tests\\file.py") for i in options)
        assert any(i.match("dir/ignore/file.py") for i in options)
        assert any(i.match("dir\\ignore\\file.py") for i in options)
Пример #6
0
    def open(self) -> None:
        py_version = get_global_option(self, "py-version")
        self._py37_plus = py_version >= (3, 7)
        self._py39_plus = py_version >= (3, 9)
        self._py310_plus = py_version >= (3, 10)

        self._should_check_typing_alias = self._py39_plus or (
            self._py37_plus and self.config.runtime_typing is False)
        self._should_check_alternative_union_syntax = self._py310_plus or (
            self._py37_plus and self.config.runtime_typing is False)
Пример #7
0
 def test_expand_modules_with_ignore(self, files_or_modules, expected):
     """Test expand_modules with a non-default value of ignore-paths."""
     ignore_list, ignore_list_re = [], []
     modules, errors = expand_modules(
         files_or_modules,
         ignore_list,
         ignore_list_re,
         get_global_option(self.checker, "ignore-paths"),
     )
     modules.sort(key=lambda d: d["name"])
     assert modules == expected
     assert not errors
Пример #8
0
    def open(self) -> None:
        py_version = get_global_option(self, "py-version")
        self._py37_plus = py_version >= (3, 7)
        self._py39_plus = py_version >= (3, 9)
        self._py310_plus = py_version >= (3, 10)

        self._should_check_typing_alias = self._py39_plus or (
            self._py37_plus and self.linter.namespace.runtime_typing is False)
        self._should_check_alternative_union_syntax = self._py310_plus or (
            self._py37_plus and self.linter.namespace.runtime_typing is False)

        self._should_check_noreturn = py_version < (3, 7, 2)
        self._should_check_callable = py_version < (3, 9, 2)
Пример #9
0
 def open(self) -> None:
     py_version = get_global_option(self, "py-version")
     self._py36_plus = py_version >= (3, 6)
Пример #10
0
 def open(self):
     """Initialize visit variables and statistics."""
     py_version = get_global_option(self, "py-version")
     self._py38_plus = py_version >= (3, 8)
     self._tryfinallys = []
     self.linter.stats.reset_node_count()