77 Dict ,
88 Iterable ,
99 List ,
10+ Dict
1011)
1112
1213import nox
1718from exasol .toolbox .nox ._shared import python_files
1819from noxconfig import PROJECT_CONFIG
1920
21+ from pathlib import Path
22+ import rich .console
23+ import tomlkit
24+ import sys
25+
2026
2127def _pylint (session : Session , files : Iterable [str ]) -> None :
2228 session .run (
@@ -79,23 +85,26 @@ def _import_lint(session: Session, path: Path) -> None:
7985
8086
8187class Dependencies :
82- def __init__ (self , illegal : dict [str , list [str ]] | None ):
88+ def __init__ (self , illegal : Dict [str , List [str ]] | None ):
8389 self ._illegal = illegal or {}
8490
8591 @staticmethod
86- def parse (pyproject_toml : str ) -> Dependencies :
92+ def parse (pyproject_toml : str ) -> " Dependencies" :
8793 def _source_filter (version ) -> bool :
88- ILLEGAL_SPECIFIERS = ["url" , "git" , "path" ]
89- return any (specifier in version for specifier in ILLEGAL_SPECIFIERS )
94+ ILLEGAL_SPECIFIERS = ['url' , 'git' , 'path' ]
95+ return any (
96+ specifier in version
97+ for specifier in ILLEGAL_SPECIFIERS
98+ )
9099
91- def find_illegal (part ) -> list [str ]:
100+ def find_illegal (part ) -> List [str ]:
92101 return [
93102 f"{ name } = { version } "
94103 for name , version in part .items ()
95104 if _source_filter (version )
96105 ]
97106
98- illegal : dict [str , list [str ]] = {}
107+ illegal : Dict [str , List [str ]] = {}
99108 toml = tomlkit .loads (pyproject_toml )
100109 poetry = toml .get ("tool" , {}).get ("poetry" , {})
101110
@@ -115,11 +124,11 @@ def find_illegal(part) -> list[str]:
115124 return Dependencies (illegal )
116125
117126 @property
118- def illegal (self ) -> dict [str , list [str ]]:
127+ def illegal (self ) -> Dict [str , List [str ]]:
119128 return self ._illegal
120129
121130
122- def report_illegal (illegal : dict [str , list [str ]], console : rich .console .Console ):
131+ def report_illegal (illegal : Dict [str , List [str ]], console : rich .console .Console ):
123132 count = sum (len (deps ) for deps in illegal .values ())
124133 suffix = "y" if count == 1 else "ies"
125134 console .print (f"{ count } illegal dependenc{ suffix } \n " , style = "red" )
@@ -148,7 +157,7 @@ def type_check(session: Session) -> None:
148157def security_lint (session : Session ) -> None :
149158 """Runs the security linter on the project"""
150159 py_files = [f"{ file } " for file in python_files (PROJECT_CONFIG .root )]
151- _security_lint (session , py_files )
160+ _security_lint (session , list ( filter ( lambda file : "test" not in file , py_files )) )
152161
153162
154163@nox .session (name = "lint:dependencies" , python = False )
0 commit comments