Skip to content

Commit 944e5e6

Browse files
committed
linters
1 parent 7583847 commit 944e5e6

File tree

10 files changed

+76
-61
lines changed

10 files changed

+76
-61
lines changed

src/aind_data_schema/imaging/instrument.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,28 @@ def validate_device_names(cls, values): # noqa: C901
165165
motorized_stages = values.get("motorized_stages")
166166
scanning_stages = values.get("scanning_stages")
167167
light_sources = values.get("light_sources")
168-
detectors = values.get("detectors")
168+
detectors = values.get("detectors")
169169
additional_devices = values.get("additional_devices")
170170
daqs = values.get("daqs")
171171

172172
if daqs is None:
173173
return values
174174

175-
for device_type in [daqs, light_sources, detectors, additional_devices, optical_tables, enclosure, lenses, fluorescence_filters, motorized_stages, scanning_stages]:
175+
for device_type in [
176+
daqs,
177+
light_sources,
178+
detectors,
179+
additional_devices,
180+
optical_tables,
181+
enclosure,
182+
lenses,
183+
fluorescence_filters,
184+
motorized_stages,
185+
scanning_stages,
186+
]:
176187
if device_type is not None:
177188
device_names += [device.name for device in device_type]
178189

179-
180190
for daq in daqs:
181191
if daq.channels is not None:
182192
for channel in daq.channels:

src/aind_data_schema/rig.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from datetime import date
66
from typing import List, Optional, Union
7+
78
from pydantic import Field, root_validator
89
from pydantic.typing import Annotated
910

@@ -43,6 +44,7 @@
4344
Wheel,
4445
)
4546

47+
4648
class Rig(AindCoreModel):
4749
"""Description of a rig"""
4850

@@ -110,7 +112,7 @@ def validate_device_names(cls, values): # noqa: C901
110112
stick_microscopes = values.get("stick_microscopes")
111113
light_sources = values.get("light_sources")
112114
patch_coords = values.get("patch_cords")
113-
detectors = values.get("detectors")
115+
detectors = values.get("detectors")
114116
digital_micromirror_devices = values.get("digital_micromirror_devices")
115117
polygonal_scanners = values.get("polygonal_scanners")
116118
pockels_cells = values.get("pockels_cells")
@@ -120,7 +122,17 @@ def validate_device_names(cls, values): # noqa: C901
120122
if daqs is None:
121123
return values
122124

123-
for device_type in [daqs, stimulus_devices, light_sources, patch_coords, detectors, digital_micromirror_devices, polygonal_scanners, pockels_cells, additional_devices]:
125+
for device_type in [
126+
daqs,
127+
stimulus_devices,
128+
light_sources,
129+
patch_coords,
130+
detectors,
131+
digital_micromirror_devices,
132+
polygonal_scanners,
133+
pockels_cells,
134+
additional_devices,
135+
]:
124136
if device_type is not None:
125137
device_names += [device.name for device in device_type]
126138

@@ -148,9 +160,9 @@ def validate_device_names(cls, values): # noqa: C901
148160
)
149161

150162
return values
151-
163+
152164
@root_validator
153-
def validate_modality(cls, v):
165+
def validate_modality(cls, v): # noqa: C901
154166
"""Validator to ensure all expected fields are present, based on given modality"""
155167

156168
modalities = v.get("modalities")

src/aind_data_schema/schema_upgrade/base_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Module to contain base code to upgrade old models"""
22

3-
from typing import Any, Type
43
from abc import ABC, abstractmethod
4+
from typing import Any, Type
55

66
from aind_data_schema.base import AindModel
77

src/aind_data_schema/schema_upgrade/data_description_upgrade.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from datetime import datetime
44
from typing import Any, Optional, Union
55

6-
76
from aind_data_schema.base import AindModel
87
from aind_data_schema.data_description import DataDescription, Funding, Institution, Modality, Platform
98
from aind_data_schema.schema_upgrade.base_upgrade import BaseModelUpgrade

tests/test_behavior.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ def test_constructors(self):
5454
bs.StimulusEpoch(
5555
stimulus=BehaviorStimulation(
5656
behavior_name="Foraging",
57-
behavior_software=[Software(
58-
name="Bonsai",
59-
version="0.1"
60-
),
57+
behavior_software=[
58+
Software(name="Bonsai", version="0.1"),
6159
],
6260
session_number=3,
6361
behavior_script=Software(

tests/test_data_description.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ def test_from_data_description(self):
309309
upgrader_0_6_2_wrong_field = DataDescriptionUpgrade(
310310
old_data_description_model=data_description_0_6_2_wrong_field
311311
)
312-
new_dd_0_6_2_wrong_field = upgrader_0_6_2_wrong_field.upgrade(
313-
funding_source=[Funding(funder=Institution.AIND)]
314-
)
312+
new_dd_0_6_2_wrong_field = upgrader_0_6_2_wrong_field.upgrade(funding_source=[Funding(funder=Institution.AIND)])
315313
derived_dd_0_6_2_wrong_field = DerivedDataDescription.from_data_description(
316314
new_dd_0_6_2_wrong_field, process_name=process_name
317315
)

tests/test_enum_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class C(AindModel):
116116
expected_exception1 = """TypeError("Only Enums are allowed. <class 'int'>")"""
117117
expected_exception2 = """ValueError('All enums must be of the same class.')"""
118118
expected_exception3 = (
119-
"ValidationError(model='C', errors=[{'loc': ('a',), 'msg': 'Value not allowed! TestEnum.BAR', "
119+
"ValidationError(model='C', errors=[{'loc': ('a',), 'msg': 'Value not allowed! TestEnum.BAR', "
120120
"'type': 'value_error'}])"
121121
)
122122
self.assertEqual(expected_exception1, repr(e1.exception))

tests/test_imaging.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from aind_data_schema.imaging import tile
1313
from aind_data_schema.manufacturers import Manufacturer
1414
from aind_data_schema.processing import Registration
15-
from aind_data_schema.utils.units import PowerValue
1615
from aind_data_schema.rig import NeuropixelsBasestation
16+
from aind_data_schema.utils.units import PowerValue
1717

1818

1919
class ImagingTests(unittest.TestCase):
@@ -189,49 +189,49 @@ def test_registration(self):
189189
assert t is not None
190190

191191
def test_validators(self):
192-
192+
"""test the validators"""
193+
193194
with self.assertRaises(ValidationError):
194195
inst.Instrument(
195-
instrument_type="diSPIM",
196-
modification_date=datetime.datetime.now(),
197-
manufacturer=Manufacturer.LIFECANVAS,
198-
objectives=[],
199-
detectors=[],
200-
light_sources=[],
201-
daqs=[
202-
NeuropixelsBasestation(
203-
basestation_firmware_version="1",
204-
bsc_firmware_version="2",
205-
slot=0,
206-
manufacturer=Manufacturer.IMEC,
207-
ports=[],
208-
computer_name="foo",
209-
channels=[
210-
DAQChannel(
211-
channel_name="123",
212-
device_name="Laser A",
213-
channel_type="Analog Output",
214-
),
215-
DAQChannel(
216-
channel_name="321",
217-
device_name="Probe A",
218-
channel_type="Analog Output",
219-
),
220-
DAQChannel(
221-
channel_name="234",
222-
device_name="Camera A",
223-
channel_type="Digital Output",
224-
),
225-
DAQChannel(
226-
channel_name="2354",
227-
device_name="Disc A",
228-
channel_type="Digital Output",
196+
instrument_type="diSPIM",
197+
modification_date=datetime.datetime.now(),
198+
manufacturer=Manufacturer.LIFECANVAS,
199+
objectives=[],
200+
detectors=[],
201+
light_sources=[],
202+
daqs=[
203+
NeuropixelsBasestation(
204+
basestation_firmware_version="1",
205+
bsc_firmware_version="2",
206+
slot=0,
207+
manufacturer=Manufacturer.IMEC,
208+
ports=[],
209+
computer_name="foo",
210+
channels=[
211+
DAQChannel(
212+
channel_name="123",
213+
device_name="Laser A",
214+
channel_type="Analog Output",
215+
),
216+
DAQChannel(
217+
channel_name="321",
218+
device_name="Probe A",
219+
channel_type="Analog Output",
220+
),
221+
DAQChannel(
222+
channel_name="234",
223+
device_name="Camera A",
224+
channel_type="Digital Output",
225+
),
226+
DAQChannel(
227+
channel_name="2354",
228+
device_name="Disc A",
229+
channel_type="Digital Output",
230+
),
231+
],
229232
),
230233
],
231-
),
232-
]
233-
)
234-
234+
)
235235

236236

237237
if __name__ == "__main__":

tests/test_rig.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ def test_validator(self):
249249
)
250250

251251
with self.assertRaises(ValidationError):
252-
253252
daqs = [
254253
NeuropixelsBasestation(
255254
basestation_firmware_version="1",
@@ -282,7 +281,7 @@ def test_validator(self):
282281
],
283282
)
284283
]
285-
284+
286285
Rig(
287286
rig_id="1234",
288287
modification_date=datetime.datetime.now(),

tests/test_schema_upgrade.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
Platform,
1818
RelatedData,
1919
)
20+
from aind_data_schema.processing import DataProcess, PipelineProcess, Processing
2021
from aind_data_schema.schema_upgrade.data_description_upgrade import (
2122
DataDescriptionUpgrade,
2223
FundingUpgrade,
2324
InstitutionUpgrade,
2425
ModalityUpgrade,
2526
)
26-
from aind_data_schema.processing import DataProcess, Processing, PipelineProcess
2727
from aind_data_schema.schema_upgrade.processing_upgrade import DataProcessUpgrade, ProcessingUpgrade
2828

29-
3029
DATA_DESCRIPTION_FILES_PATH = Path(__file__).parent / "resources" / "ephys_data_description"
3130
PROCESSING_FILES_PATH = Path(__file__).parent / "resources" / "ephys_processing"
3231

0 commit comments

Comments
 (0)