55``*.ipynb`` files and injecting the parsed files, during the loading
66of the CLI argv and config of ``flake8``.
77"""
8+ from __future__ import annotations
89
910import logging
1011import os
1112import sys
1213from typing import Any
1314from typing import Callable
14- from typing import List
15- from typing import Optional
16- from typing import Tuple
1715
1816from flake8 import __version__ as flake_version
1917from flake8 import defaults
3331
3432
3533def get_notebooks_from_args (
36- args : List [str ], exclude : List [str ] = ["*.tox/*" , "*.ipynb_checkpoints*" ]
37- ) -> Tuple [ List [str ], List [str ]]:
34+ args : list [str ], exclude : list [str ] = ["*.tox/*" , "*.ipynb_checkpoints*" ]
35+ ) -> tuple [ list [str ], list [str ]]:
3836 """Extract the absolute paths to notebooks.
3937
4038 The paths are relative to the current directory or
4139 to the CLI passes files/folder and returned as list.
4240
4341 Parameters
4442 ----------
45- args : List [str]
43+ args : list [str]
4644 The left over arguments that were not parsed by :attr:`option_manager`
47- exclude : List [str], optional
45+ exclude : list [str]
4846 File-/Folderpatterns that should be excluded,
4947 by default ["*.tox/*", "*.ipynb_checkpoints*"]
5048
5149 Returns
5250 -------
53- Tuple[List [str],List [str]]
51+ tuple[list [str], list [str]]
5452 List of found notebooks absolute paths.
5553 """
5654
57- def is_notebook (file_path : str , nb_list : List [str ], root : str = "." ) -> bool :
55+ def is_notebook (file_path : str , nb_list : list [str ], root : str = "." ) -> bool :
5856 """Check if a file is a notebook and appends it to nb_list if it is.
5957
6058 Parameters
6159 ----------
6260 file_path : str
6361 File to check if it is a notebook
64- nb_list : List [str]
62+ nb_list : list [str]
6563 List of notebooks
6664 root : str
6765 Root directory, by default "."
@@ -77,7 +75,7 @@ def is_notebook(file_path: str, nb_list: List[str], root: str = ".") -> bool:
7775 return True
7876 return False
7977
80- nb_list : List [str ] = []
78+ nb_list : list [str ] = []
8179 if not args :
8280 args = [os .curdir ]
8381 for index , arg in list (enumerate (args ))[::- 1 ]:
@@ -102,12 +100,12 @@ def hack_option_manager_generate_versions(
102100
103101 Parameters
104102 ----------
105- generate_versions : Callable
103+ generate_versions : Callable[..., str]
106104 option_manager.generate_versions of flake8.options.manager.OptionManager
107105
108106 Returns
109107 -------
110- Callable
108+ Callable[..., str]
111109 hacked_generate_versions
112110 """
113111
@@ -128,12 +126,11 @@ def hacked_generate_versions(*args: Any, **kwargs: Any) -> str:
128126 """
129127 original_output = generate_versions (* args , ** kwargs )
130128 format_str = "%(name)s: %(version)s"
131- join_on = ", "
132129 additional_output = format_str % {
133130 "name" : "flake8" ,
134131 "version" : flake_version ,
135132 }
136- return f"{ additional_output } { join_on } { original_output } "
133+ return f"{ additional_output } , { original_output } "
137134
138135 return hacked_generate_versions
139136
@@ -257,7 +254,7 @@ def hack_options(self) -> None:
257254 )
258255
259256 @staticmethod
260- def hack_args (args : List [str ], exclude : List [str ]) -> List [str ]:
257+ def hack_args (args : list [str ], exclude : list [str ]) -> list [str ]:
261258 r"""Update args with ``*.ipynb`` files.
262259
263260 Checks the passed args if ``*.ipynb`` can be found and
@@ -266,14 +263,14 @@ def hack_args(args: List[str], exclude: List[str]) -> List[str]:
266263
267264 Parameters
268265 ----------
269- args : List [str]
266+ args : list [str]
270267 List of commandline arguments provided to ``flake8_nb``
271- exclude : List [str]
268+ exclude : list [str]
272269 File-/Folderpatterns that should be excluded
273270
274271 Returns
275272 -------
276- List [str]
273+ list [str]
277274 The original args + intermediate parsed ``*.ipynb`` files.
278275 """
279276 args , nb_list = get_notebooks_from_args (args , exclude = exclude )
@@ -282,7 +279,7 @@ def hack_args(args: List[str], exclude: List[str]) -> List[str]:
282279
283280 def parse_configuration_and_cli_legacy (
284281 self ,
285- argv : Optional [ List [ str ]] = None ,
282+ argv : list [ str ] | None = None ,
286283 ) -> None :
287284 """Compat version of self.parse_configuration_and_cli to work with flake8 >=3.7.0,<= 3.7.9 .
288285
@@ -292,7 +289,7 @@ def parse_configuration_and_cli_legacy(
292289
293290 Parameters
294291 ----------
295- argv: List [str]
292+ argv: list [str] | None
296293 Command-line arguments passed in directly.
297294 """
298295 if self .options is None and self .args is None : # type: ignore # pragma: no branch
@@ -315,15 +312,15 @@ def parse_configuration_and_cli_legacy(
315312 self .formatting_plugins .provide_options (self .option_manager , self .options , self .args )
316313
317314 def parse_configuration_and_cli (
318- self , config_finder : config .ConfigFileFinder , argv : List [str ]
315+ self , config_finder : config .ConfigFileFinder , argv : list [str ]
319316 ) -> None :
320317 """Parse configuration files and the CLI options.
321318
322319 Parameters
323320 ----------
324321 config_finder: config.ConfigFileFinder
325322 The finder for finding and reading configuration files.
326- argv: List [str]
323+ argv: list [str]
327324 Command-line arguments passed in directly.
328325 """
329326 self .options , self .args = aggregator .aggregate_options (
0 commit comments