@@ -210,9 +210,10 @@ def parse_cli_args(argv: Optional[List[str]] = None) -> argparse.Namespace:
210210 parser .add_argument ("-h" , "--help" , action = "help" , default = argparse .SUPPRESS ,
211211 help = "Diese Hilfe anzeigen" )
212212
213- args = parser .parse_args (sys .argv [1 :] if argv is None else argv )
213+ args , remaining = parser .parse_known_args (sys .argv [1 :] if argv is None else argv )
214214 if args .open is None and args .file :
215215 args .open = args .file
216+ args ._remaining = remaining
216217 return args
217218
218219
@@ -1237,6 +1238,26 @@ def _check_available_linters(self):
12371238 """Prüft welche Linter verfügbar sind"""
12381239 self .has_pylint = shutil .which ("pylint" ) is not None
12391240 self .has_flake8 = shutil .which ("flake8" ) is not None
1241+ if not self .has_flake8 :
1242+ try :
1243+ subprocess .run ([sys .executable , "-m" , "flake8" , "--version" ],
1244+ capture_output = True , timeout = 5 )
1245+ self .has_flake8 = True
1246+ self ._flake8_via_module = True
1247+ except Exception :
1248+ self ._flake8_via_module = False
1249+ else :
1250+ self ._flake8_via_module = False
1251+ if not self .has_pylint :
1252+ try :
1253+ subprocess .run ([sys .executable , "-m" , "pylint" , "--version" ],
1254+ capture_output = True , timeout = 5 )
1255+ self .has_pylint = True
1256+ self ._pylint_via_module = True
1257+ except Exception :
1258+ self ._pylint_via_module = False
1259+ else :
1260+ self ._pylint_via_module = False
12401261
12411262 def run_linter (self , code : str , file_path : Optional [str ] = None ) -> List [Dict ]:
12421263 """Führt Linter aus und gibt Ergebnisse zurück"""
@@ -1271,8 +1292,10 @@ def _run_flake8(self, file_path: str) -> List[Dict]:
12711292 """Führt Flake8 aus"""
12721293 results = []
12731294 try :
1295+ cmd = ([sys .executable , "-m" , "flake8" ] if getattr (self , '_flake8_via_module' , False )
1296+ else ["flake8" ])
12741297 proc = subprocess .run (
1275- ["flake8" , "--format=%(row)d:%(col)d:%(code)s:%(text)s" , file_path ],
1298+ [* cmd , "--format=%(row)d:%(col)d:%(code)s:%(text)s" , file_path ],
12761299 capture_output = True , text = True , timeout = 10
12771300 )
12781301
@@ -1299,8 +1322,10 @@ def _run_pylint(self, file_path: str) -> List[Dict]:
12991322 """Führt Pylint aus"""
13001323 results = []
13011324 try :
1325+ cmd = ([sys .executable , "-m" , "pylint" ] if getattr (self , '_pylint_via_module' , False )
1326+ else ["pylint" ])
13021327 proc = subprocess .run (
1303- ["pylint" , "--output-format=text" , "--msg-template={line}:{column}:{msg_id}:{msg}" ,
1328+ [* cmd , "--output-format=text" , "--msg-template={line}:{column}:{msg_id}:{msg}" ,
13041329 file_path ],
13051330 capture_output = True , text = True , timeout = 30
13061331 )
@@ -4137,9 +4162,8 @@ def main(argv: Optional[List[str]] = None):
41374162 if args .lint :
41384163 sys .exit (run_lint_cli (args .lint ))
41394164
4140- cli_args = list (sys .argv [1 :] if argv is None else argv )
41414165 startup_file = args .open
4142- app = QApplication ([sys .argv [0 ], * cli_args ] )
4166+ app = QApplication ([sys .argv [0 ]] + args . _remaining )
41434167 icon_path = Path (__file__ ).with_name ("PythonBox.ico" )
41444168 icon = QIcon (str (icon_path )) if icon_path .exists () else QIcon ()
41454169 if not icon .isNull ():
0 commit comments