Skip to content

Commit 4e9ff62

Browse files
Merge pull request #2943 from alicevision/dev/linting
Apply linting suggestions
2 parents 69b518c + 705e7f0 commit 4e9ff62

27 files changed

+455
-428
lines changed

.git-blame-ignore-revs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# [tests] Linting: Remove trailing whitespaces
2+
5fe886b6b08fa19082dc0e1bf837fa34c2e2de2d
3+
# [core] Linting: Remove remaining trailing whitespaces
4+
a44537b65a7c53c89c16e71ae207f37fa6554832
5+
# Linting: Fix E203, E225, E231, E261, E302, E303 and W292 warnings
6+
1b5664c8cc54c55fae58a5be9bf63e9af2f5af95
7+
# [ui] Linting: Remove all trailing whitespaces
8+
18d7f609b1a5cd7c43f970770374b649019c1e73
9+
# [core] Linting: Fix import order
10+
aae05532b2409e3bd4c119646afc08656a916cb4
11+
# [core] Linting: Remove all trailing whitespaces
12+
81394d7def1fcbc08cbc2a8721bc1f0a86fe8cc6
13+
# [desc] Linting: Remove trailing whitespaces
14+
0a2ab8cab4f79191b0e7364416701ba561e75b6a
15+
# [desc] Linting: Fix order of the imported modules
16+
adf67e33533a75f5b280e0ee3fc0ece82307199e
117
# [build] `setup.py`: Use double quotes everywhere
218
571de38ef1a9e72e6c1d2a997b60de5bd3caa5bf
319
# [bin] `meshroom_batch`: Minor clean-up in the file

meshroom/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import sys
66

7+
78
class VersionStatus(Enum):
89
release = 1
910
develop = 2
@@ -42,16 +43,18 @@ class VersionStatus(Enum):
4243

4344
useMultiChunks = util.strtobool(os.environ.get("MESHROOM_USE_MULTI_CHUNKS", "True"))
4445

45-
# Logging
4646

47+
# Logging
4748
def addTraceLevel():
4849
""" From https://stackoverflow.com/a/35804945 """
4950
levelName, methodName, levelNum = 'TRACE', 'trace', logging.DEBUG - 5
5051
if hasattr(logging, levelName) or hasattr(logging, methodName)or hasattr(logging.getLoggerClass(), methodName):
51-
return
52+
return
53+
5254
def logForLevel(self, message, *args, **kwargs):
5355
if self.isEnabledFor(levelNum):
5456
self._log(levelNum, message, args, **kwargs)
57+
5558
def logToRoot(message, *args, **kwargs):
5659
logging.log(levelNum, message, *args, **kwargs)
5760

@@ -60,6 +63,7 @@ def logToRoot(message, *args, **kwargs):
6063
setattr(logging.getLoggerClass(), methodName, logForLevel)
6164
setattr(logging, methodName, logToRoot)
6265

66+
6367
addTraceLevel()
6468
logStringToPython = {
6569
'fatal': logging.CRITICAL,

meshroom/core/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def loadClasses(folder: str, packageName: str, classType: type) -> list[type]:
7878
else package.__name__
7979
packageVersion = getattr(package, "__version__", None)
8080
packagePath = os.path.dirname(package.__file__)
81-
except Exception as e:
82-
tb = traceback.extract_tb(e.__traceback__)
81+
except Exception as exc:
82+
tb = traceback.extract_tb(exc.__traceback__)
8383
last_call = tb[-1]
84-
logging.warning(f' * Failed to load package "{packageName}" from folder "{resolvedFolder}" ({type(e).__name__}): {str(e)}\n'
84+
logging.warning(f' * Failed to load package "{packageName}" from folder "{resolvedFolder}" ({type(exc).__name__}): {str(exc)}\n'
8585
# filename:lineNumber functionName
8686
f'{last_call.filename}:{last_call.lineno} {last_call.name}\n'
8787
# line of code with the error
@@ -114,18 +114,18 @@ def loadClasses(folder: str, packageName: str, classType: type) -> list[type]:
114114
if classType == desc.BaseNode:
115115
nodePlugin = NodePlugin(p)
116116
if nodePlugin.errors:
117-
errors.append(" * {}: The following parameters do not have valid " \
118-
"default values/ranges: {}".format(pluginName, ", ".join(nodePlugin.errors)))
117+
errors.append(f" * {pluginName}: The following parameters do not have valid "
118+
f"default values/ranges: {', '.join(nodePlugin.errors)}")
119119
classes.append(nodePlugin)
120120
else:
121121
classes.append(p)
122-
except Exception as e:
122+
except Exception as exc:
123123
if classType == BaseSubmitter:
124124
logging.warning(f" Could not load submitter {pluginName} from package '{package.__name__}'")
125125
else:
126-
tb = traceback.extract_tb(e.__traceback__)
126+
tb = traceback.extract_tb(exc.__traceback__)
127127
last_call = tb[-1]
128-
errors.append(f' * {pluginName} ({type(e).__name__}): {e}\n'
128+
errors.append(f' * {pluginName} ({type(exc).__name__}): {exc}\n'
129129
# filename:lineNumber functionName
130130
f'{last_call.filename}:{last_call.lineno} {last_call.name}\n'
131131
# line of code with the error

0 commit comments

Comments
 (0)