Skip to content

Commit 21d26cc

Browse files
authored
Add pre-commit linter (#54)
* Add pre-commit linter and checks * Add precommit as dev dependency * Add merged session.py
1 parent f78ce4e commit 21d26cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+799
-220
lines changed

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/charliermarsh/ruff-pre-commit
5+
rev: 'v0.0.267'
6+
hooks:
7+
- id: ruff
8+
args: [ --fix, --exit-non-zero-on-fix ]
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v3.2.0
11+
hooks:
12+
- id: trailing-whitespace
13+
- id: end-of-file-fixer
14+
- id: check-ast
15+
- id: check-yaml
16+
- id: check-added-large-files

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[python]": {
3+
"editor.defaultFormatter": "ms-python.black-formatter"
4+
},
5+
"python.formatting.provider": "none"
6+
}

deepview_profile/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import argparse
2-
import enum
32
import sys
43

54
import deepview_profile

deepview_profile/analysis/request_manager.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from concurrent.futures import ThreadPoolExecutor
55

66
from deepview_profile.analysis.runner import analyze_project
7-
from deepview_profile.config import Config
87
from deepview_profile.exceptions import AnalysisError
98
from deepview_profile.nvml import NVML
109
import deepview_profile.protocol_gen.innpv_pb2 as pm
@@ -135,7 +134,7 @@ def _handle_analysis_request(self, analysis_request, context):
135134
except AnalysisError as ex:
136135
self._enqueue_response(self._send_analysis_error, ex, context)
137136

138-
except:
137+
except Exception:
139138
logger.exception(
140139
'Exception occurred when handling analysis request.')
141140
self._enqueue_response(
@@ -164,38 +163,38 @@ def _send_breakdown_response(self, breakdown, context):
164163
# Called from the main executor. Do not call directly!
165164
try:
166165
self._message_sender.send_breakdown_response(breakdown, context)
167-
except:
166+
except Exception:
168167
logger.exception(
169168
'Exception occurred when sending a breakdown response.')
170169

171170
def _send_analysis_error(self, exception, context):
172171
# Called from the main executor. Do not call directly!
173172
try:
174173
self._message_sender.send_analysis_error(exception, context)
175-
except:
174+
except Exception:
176175
logger.exception(
177176
'Exception occurred when sending an analysis error.')
178177

179178
def _send_throughput_response(self, throughput, context):
180179
# Called from the main executor. Do not call directly!
181180
try:
182181
self._message_sender.send_throughput_response(throughput, context)
183-
except:
182+
except Exception:
184183
logger.exception(
185184
'Exception occurred when sending a throughput response.')
186185

187186
def _send_habitat_response(self, habitat_resp, context):
188187
# Called from the main executor. Do not call directly!
189188
try:
190189
self._message_sender.send_habitat_response(habitat_resp, context)
191-
except:
190+
except Exception:
192191
logger.exception(
193192
'Exception occurred when sending a DeepView.Predict response.')
194193

195194
def _send_energy_response(self, energy_resp, context):
196195
# Called from the main executor. Do not call directly!
197196
try:
198197
self._message_sender.send_energy_response(energy_resp, context)
199-
except:
198+
except Exception:
200199
logger.exception(
201-
'Exception occurred when sending an energy response.')
200+
'Exception occurred when sending an energy response.')

0 commit comments

Comments
 (0)