Skip to content

Commit

Permalink
Use python-typing-update on pylint/lint directory
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Apr 14, 2022
1 parent 5bff0d8 commit 9dd11f8
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 97 deletions.
20 changes: 11 additions & 9 deletions pylint/lint/expand_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt

from __future__ import annotations

import os
import sys
from typing import List, Pattern, Tuple
from typing import Pattern

from astroid import modutils

Expand Down Expand Up @@ -38,22 +40,22 @@ def get_python_path(filepath: str) -> str:
return os.getcwd()


def _is_in_ignore_list_re(element: str, ignore_list_re: List[Pattern]) -> bool:
def _is_in_ignore_list_re(element: str, ignore_list_re: list[Pattern]) -> bool:
"""Determines if the element is matched in a regex ignore-list."""
return any(file_pattern.match(element) for file_pattern in ignore_list_re)


def expand_modules(
files_or_modules: List[str],
ignore_list: List[str],
ignore_list_re: List[Pattern],
ignore_list_paths_re: List[Pattern[str]],
) -> Tuple[List[ModuleDescriptionDict], List[ErrorDescriptionDict]]:
files_or_modules: list[str],
ignore_list: list[str],
ignore_list_re: list[Pattern],
ignore_list_paths_re: list[Pattern[str]],
) -> tuple[list[ModuleDescriptionDict], list[ErrorDescriptionDict]]:
"""Take a list of files/modules/packages and return the list of tuple
(file, module name) which have to be actually checked
"""
result: List[ModuleDescriptionDict] = []
errors: List[ErrorDescriptionDict] = []
result: list[ModuleDescriptionDict] = []
errors: list[ErrorDescriptionDict] = []
path = sys.path.copy()

for something in files_or_modules:
Expand Down
23 changes: 8 additions & 15 deletions pylint/lint/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt

from __future__ import annotations

import collections
import functools
import warnings
from typing import (
TYPE_CHECKING,
Any,
DefaultDict,
Iterable,
List,
Sequence,
Tuple,
Union,
)
from typing import TYPE_CHECKING, Any, DefaultDict, Iterable, Sequence

import dill

Expand Down Expand Up @@ -50,7 +43,7 @@ def _get_new_args(message):


def _worker_initialize(
linter: bytes, arguments: Union[None, str, Sequence[str]] = None
linter: bytes, arguments: None | str | Sequence[str] = None
) -> None:
"""Function called to initialize a worker for a Process within a multiprocessing Pool.
Expand All @@ -71,8 +64,8 @@ def _worker_initialize(

def _worker_check_single_file(
file_item: FileItem,
) -> Tuple[
int, Any, str, Any, List[Tuple[Any, ...]], LinterStats, Any, DefaultDict[Any, List]
) -> tuple[
int, Any, str, Any, list[tuple[Any, ...]], LinterStats, Any, DefaultDict[Any, list]
]:
if not _worker_linter:
raise Exception("Worker linter not yet initialised")
Expand Down Expand Up @@ -129,10 +122,10 @@ def _merge_mapreduce_data(linter, all_mapreduce_data):


def check_parallel(
linter: "PyLinter",
linter: PyLinter,
jobs: int,
files: Iterable[FileItem],
arguments: Union[None, str, Sequence[str]] = None,
arguments: None | str | Sequence[str] = None,
) -> None:
"""Use the given linter to lint the files with given amount of workers (jobs).
Expand Down
Loading

0 comments on commit 9dd11f8

Please sign in to comment.