Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.8.15
rev: 0.9.2
hooks:
- id: uv-export
args: ["--group", "prod", "--no-dev", "--frozen", "--output-file=requirements.txt"]
Expand All @@ -39,13 +39,13 @@ repos:
# - id: djlint-django

- repo: https://github.com/adamchainz/django-upgrade
rev: "1.27.0"
rev: "1.29.0"
hooks:
- id: django-upgrade
args: ["--target-version", "4.2"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.12.11"
rev: "v0.14.0"
hooks:
- id: ruff
args: ["--fix", "--unsafe-fixes"]
Expand Down
2 changes: 1 addition & 1 deletion backend/proteins/extrest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def execute(self):
p = Protein.objects.get(id=self.id) # in case it's changed
for attr, newval in self.changes.items():
if attr == "parent_organism" and isinstance(newval, int):
org, created = Organism.objects.get_or_create(id=newval)
org, _created = Organism.objects.get_or_create(id=newval)
p.parent_organism = org
else:
setattr(p, attr, newval)
Expand Down
4 changes: 2 additions & 2 deletions backend/proteins/forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def save(self, commit=True):
obj = super().save(commit=False)
doi = self.cleaned_data.get("reference_doi")
if doi:
ref, created = Reference.objects.get_or_create(doi=doi)
ref, _created = Reference.objects.get_or_create(doi=doi)
obj.reference = ref
if commit:
obj.save()
Expand Down Expand Up @@ -635,7 +635,7 @@ def save(self, commit=True):
obj = super().save(commit=False)
doi = self.cleaned_data.get("reference_doi")
if doi:
ref, created = Reference.objects.get_or_create(doi=doi)
ref, _created = Reference.objects.get_or_create(doi=doi)
obj.reference = ref
if commit:
obj.save()
Expand Down
2 changes: 1 addition & 1 deletion backend/proteins/forms/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def clean_file(self):
filetext += chunk.decode("utf-8")
except AttributeError:
filetext += chunk
x, y, headers = text_to_spectra(filetext)
x, y, _headers = text_to_spectra(filetext)
if not len(y):
self.add_error("file", "Did not find a data column in the provided file")
if not len(x):
Expand Down
4 changes: 2 additions & 2 deletions backend/proteins/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_ids_already_exist(self):

class TestStateForm(TestCase):
def setUp(self):
self.t, c = Protein.objects.get_or_create(name="Test Protein")
self.t, _c = Protein.objects.get_or_create(name="Test Protein")
State.objects.get_or_create(protein=self.t)

def test_clean_state_success(self):
Expand All @@ -132,7 +132,7 @@ def test_nondark_state_exemmax_required(self):

class TestCollectionForm(TestCase):
def setUp(self):
self.p, c = Protein.objects.get_or_create(name="Test Protein")
self.p, _c = Protein.objects.get_or_create(name="Test Protein")
self.userA = self.make_user("userA", "userApassword")
self.userB = self.make_user("userB", "userBpassword")

Expand Down
6 changes: 3 additions & 3 deletions backend/proteins/util/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def import2P():
with open(infile) as f:
text = f.read()

x, y, headers = text_to_spectra(text)
x, y, _headers = text_to_spectra(text)
D = zip_wave_data(x, y[0])

sf = SpectrumForm(
Expand All @@ -477,7 +477,7 @@ def import2P():
P.default_state.save()

# add drobizhev reference
ref, created = Reference.objects.get_or_create(doi="10.1038/nmeth.1596")
ref, _created = Reference.objects.get_or_create(doi="10.1038/nmeth.1596")
P.references.add(ref)
P.save()
print(f"Successfuly import 2P spectrum for {P.name}")
Expand Down Expand Up @@ -965,7 +965,7 @@ def import_chroma():

def import_lights():
file = os.path.join(BASEDIR, "_data/broadband_light_spectra.csv")
objs, errs = import_csv_spectra(file, categories=Spectrum.LIGHT, stypes=Spectrum.PD)
objs, _errs = import_csv_spectra(file, categories=Spectrum.LIGHT, stypes=Spectrum.PD)
for obj in objs:
obj.owner.created_by = User.objects.first()
obj.created_by = User.objects.first()
Expand Down
2 changes: 1 addition & 1 deletion backend/proteins/util/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def reimport_filter_spectrum(obj):
text = fetch_semrock_part(obj.part)
elif obj.manufacturer.lower() == "chroma":
text = fetch_chroma_part(obj.part)
waves, data, headers = text_to_spectra(text)
waves, data, _headers = text_to_spectra(text)
D = zip_wave_data(waves, data[0])
obj.spectrum.data = D
obj.spectrum.save()
Expand Down
4 changes: 2 additions & 2 deletions backend/proteins/util/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def norm2one(y):


def step_size(lol):
x, y = zip(*lol)
x, _y = zip(*lol)
s = set(np.subtract(x[1:], x[:-1]))
if len(s) != 1: # multiple step sizes
return 0
Expand Down Expand Up @@ -107,7 +107,7 @@ def interp2int(x, y, s=1):
from proteins.util.importers import text_to_spectra

def file2spectra(file, dtype="", getcol=0):
waves, outdata, headers = text_to_spectra(file)
waves, outdata, _headers = text_to_spectra(file)
x = waves
y = outdata[getcol]
spectra = [list(i) for i in zip(x, y)]
Expand Down
4 changes: 2 additions & 2 deletions backend/proteins/views/protein.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def add_reference(request, slug=None):
with reversion.create_revision():
doi = request.POST.get("reference_doi").lower()
p = Protein.objects.get(slug=slug)
ref, created = Reference.objects.get_or_create(doi=doi)
ref, _created = Reference.objects.get_or_create(doi=doi)
p.references.add(ref)
if not request.user.is_staff:
p.status = "pending"
Expand Down Expand Up @@ -712,7 +712,7 @@ def add_protein_excerpt(request, slug=None):
p = Protein.objects.get(slug=slug)
content = request.POST.get("excerpt_content")
if content:
ref, created = Reference.objects.get_or_create(doi=doi)
ref, _created = Reference.objects.get_or_create(doi=doi)
p.references.add(ref)
excerpt = Excerpt.objects.create(reference=ref, content=strip_tags(content), created_by=request.user)
excerpt.proteins.add(p)
Expand Down
Loading