11""" Logging, config, constants & utilities """
22
3+ from __future__ import annotations
4+
35import copy
46import logging
57import os
@@ -89,6 +91,7 @@ class ReferenceError(GeneralError):
8991
9092class FetchError (GeneralError ):
9193 """ Fatal error in helper command while fetching """
94+
9295 # Keep previously used format of the message
9396
9497 def __str__ (self ):
@@ -194,7 +197,7 @@ def info(message, newline=True):
194197# Filtering
195198# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
196199
197- def evaluate (expression , data , _node = None ):
200+ def evaluate (expression : str , data : dict [ str , Any ], _node : fmf . base . Tree | None = None ) -> Any :
198201 """
199202 Evaluate arbitrary Python expression against given data
200203
@@ -210,7 +213,8 @@ def evaluate(expression, data, _node=None):
210213 raise FilterError ("Internal key is not defined: {}" .format (error ))
211214
212215
213- def filter (filter , data , sensitive = True , regexp = False ):
216+ def filter (filter : str , data : dict [str , Any ],
217+ sensitive : bool = True , regexp : bool = False ) -> bool :
214218 """
215219 Return true if provided filter matches given dictionary of values
216220
@@ -323,6 +327,7 @@ def check_clause(clause):
323327 return any ([check_clause (clause )
324328 for clause in re .split (r"\s*\|\s*" , filter )])
325329
330+
326331# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
327332# Logging
328333# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -620,6 +625,7 @@ def invalidate_cache():
620625 if issues : # pragma: no cover
621626 raise GeneralError ("\n " .join (issues ))
622627
628+
623629# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
624630# Fetch Tree from the Remote Repository
625631# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -755,7 +761,7 @@ def fetch_repo(url, ref=None, destination=None, env=None):
755761 if os .path .isfile (os .path .join (destination , '.git' , 'shallow' )):
756762 # Make fetch get all remote refs (branches...)
757763 run (["git" , "config" , "remote.origin.fetch" ,
758- "+refs/heads/*:refs/remotes/origin/*" ], cwd = destination )
764+ "+refs/heads/*:refs/remotes/origin/*" ], cwd = destination )
759765 # Fetch the whole history
760766 run (['git' , 'fetch' , '--unshallow' ], cwd = destination )
761767 run (['git' , 'checkout' , '-f' , ref ], cwd = destination , env = env )
0 commit comments