11from __future__ import annotations
22
3+ import sys
4+ from collections .abc import Iterable
5+ from pathlib import Path
36from typing import (
4- Iterable ,
7+ Dict ,
58 List ,
6- Dict
79)
810
911import nox
12+ import rich .console
13+ import tomlkit
1014from nox import Session
1115
1216from exasol .toolbox .nox ._shared import python_files
1317from noxconfig import PROJECT_CONFIG
1418
15- from pathlib import Path
16- import rich .console
17- import tomlkit
18- import sys
19-
2019
2120def _pylint (session : Session , files : Iterable [str ]) -> None :
2221 session .run (
@@ -75,26 +74,23 @@ def _security_lint(session: Session, files: Iterable[str]) -> None:
7574
7675
7776class Dependencies :
78- def __init__ (self , illegal : Dict [str , List [str ]] | None ):
77+ def __init__ (self , illegal : dict [str , list [str ]] | None ):
7978 self ._illegal = illegal or {}
8079
8180 @staticmethod
82- def parse (pyproject_toml : str ) -> " Dependencies" :
81+ def parse (pyproject_toml : str ) -> Dependencies :
8382 def _source_filter (version ) -> bool :
84- ILLEGAL_SPECIFIERS = ['url' , 'git' , 'path' ]
85- return any (
86- specifier in version
87- for specifier in ILLEGAL_SPECIFIERS
88- )
83+ ILLEGAL_SPECIFIERS = ["url" , "git" , "path" ]
84+ return any (specifier in version for specifier in ILLEGAL_SPECIFIERS )
8985
90- def find_illegal (part ) -> List [str ]:
86+ def find_illegal (part ) -> list [str ]:
9187 return [
9288 f"{ name } = { version } "
9389 for name , version in part .items ()
9490 if _source_filter (version )
9591 ]
9692
97- illegal : Dict [str , List [str ]] = {}
93+ illegal : dict [str , list [str ]] = {}
9894 toml = tomlkit .loads (pyproject_toml )
9995 poetry = toml .get ("tool" , {}).get ("poetry" , {})
10096
@@ -114,11 +110,11 @@ def find_illegal(part) -> List[str]:
114110 return Dependencies (illegal )
115111
116112 @property
117- def illegal (self ) -> Dict [str , List [str ]]:
113+ def illegal (self ) -> dict [str , list [str ]]:
118114 return self ._illegal
119115
120116
121- def report_illegal (illegal : Dict [str , List [str ]], console : rich .console .Console ):
117+ def report_illegal (illegal : dict [str , list [str ]], console : rich .console .Console ):
122118 count = sum (len (deps ) for deps in illegal .values ())
123119 suffix = "y" if count == 1 else "ies"
124120 console .print (f"{ count } illegal dependenc{ suffix } \n " , style = "red" )
@@ -158,4 +154,4 @@ def dependency_check(session: Session) -> None:
158154 console = rich .console .Console ()
159155 if illegal := dependencies .illegal :
160156 report_illegal (illegal , console )
161- sys .exit (1 )
157+ sys .exit (1 )
0 commit comments