523 batch_size=256,
524 epoch=20,
525 )
526 except Exception:527 logger.error("NN prediction failed")
528 date, level = ([], []), ([], [], [])
529 predict_plot = plot_prediction(date, level)
52 float(e["stageScale"]["typicalRangeLow"]),
53 float(e["stageScale"]["typicalRangeHigh"]),
54 )
55 except Exception: 56 typical_range = None
57
58 try:
68 town=town,
69 )
70 stations.append(s)
71 except Exception: 72 # Not all required data on the station was available, so
73 # skip over
74 pass
225 if use_pretrained:
226 try:
227 model = keras.models.load_model("./cache/{}.hdf5".format(station_name))
228 except Exception:229 print(
230 "No pre-trained model for {} found, training a model for it now.".format(
231 station_name
173 try:
174 levels.append(measure["value"])
175 dates.append(d)
176 except Exception:177 continue
178
179 return dates, levels
If the except block catches a very general exception, it is likely to catch any unrelated errors too. Try to be more explicit about which exception(s) you're trying to catch.
If you need to catch every other exception, then mark it as intentional by
adding a # skipcq
comment.
try:
x = a / b
except Exception:
x = a / (b + 1)
try:
line = input('Enter numbers:')
numbers = [int(i) for i in line.split()]
except BaseException:
print('Only use numbers for the input')
try:
x = a / b
except ZeroDivisionError:
x = a / (b + 1)
try:
event_loop.run()
except Exception as exc: # skipcq: PYL-W0703 - Loop can sometimes crash.
sentry.report(exc)
try:
line = input('Enter numbers:')
numbers = [int(i) for i in line.split()]
except ValueError:
print('Only use numbers for the input')