File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- from collections . abc import Iterable
3+ from typing import Iterable
44
55import nox
66from nox import Session
@@ -27,7 +27,7 @@ def _pyupgrade(session: Session, files: Iterable[str]) -> None:
2727 "poetry" ,
2828 "run" ,
2929 "pyupgrade" ,
30- "--py39 -plus" ,
30+ "--py38 -plus" ,
3131 "--exit-zero-even-if-changed" ,
3232 * files ,
3333 )
Original file line number Diff line number Diff line change 22
33import argparse
44import sys
5- from collections .abc import Iterable
65from pathlib import Path
76from typing import (
87 Dict ,
8+ Iterable ,
99 List ,
1010)
1111
@@ -160,3 +160,34 @@ def dependency_check(session: Session) -> None:
160160 if illegal := dependencies .illegal :
161161 report_illegal (illegal , console )
162162 sys .exit (1 )
163+
164+
165+ @nox .session (name = "lint:import" , python = False )
166+ def import_lint (session : Session ) -> None :
167+ """(experimental) Runs import linter on the project"""
168+ parser = argparse .ArgumentParser (
169+ usage = "nox -s import-lint -- [options]" ,
170+ description = "Runs the import linter on the project" ,
171+ )
172+ parser .add_argument (
173+ "-c" ,
174+ "--config" ,
175+ type = str ,
176+ help = "path to the configuration file for the importlinter" ,
177+ metavar = "TEXT" ,
178+ )
179+
180+ args : argparse .Namespace = parser .parse_args (args = session .posargs )
181+ file : str = args .config
182+ path : Path | None = None
183+ if file is None :
184+ path = getattr (
185+ PROJECT_CONFIG , "import_linter_config" , Path (".import_linter_config" )
186+ )
187+ else :
188+ path = Path (file )
189+ if not path .exists ():
190+ session .error (
191+ "Please make sure you have a configuration file for the importlinter"
192+ )
193+ _import_lint (session = session , path = path )
You can’t perform that action at this time.
0 commit comments