Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable check for unused variables (F841) #2099

Merged
merged 1 commit into from
Aug 6, 2022
Merged
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
1 change: 0 additions & 1 deletion src/bika/lims/browser/client/views/attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def folderitem(self, obj, item, index):
obj = api.get_object(obj)
obj_url = api.get_url(obj)
file = obj.getAttachmentFile()
icon = file.icon
item['AttachmentFile'] = file.filename()
item['AttachmentType'] = obj.getAttachmentType().Title()
item['AttachmentType'] = obj.getAttachmentType().Title()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(self, context, request, report=None):
def __call__(self):
bc = getToolByName(self.context, 'senaite_catalog')
self.report_content = {}
parm_lines = {}
parms = []
headings = {}
headings['header'] = _("Samples not invoiced")
Expand Down Expand Up @@ -86,11 +85,6 @@ def __call__(self):
}

datalines = []
clients = {}
sampletypes = {}
samplepoints = {}
categories = {}
services = {}

for ar_proxy in bc(query):
ar = ar_proxy.getObject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __call__(self):
bac = getToolByName(self.context, 'senaite_catalog_analysis')
rc = getToolByName(self.context, 'reference_catalog')
self.report_content = {}
parm_lines = {}
parms = []
headings = {}
headings['header'] = _("Analyses per sample type")
Expand Down
4 changes: 1 addition & 3 deletions src/bika/lims/browser/widgets/scheduleinputwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ class ScheduleInputWidget(TypesWidget):
security = ClassSecurityInfo()

def process_form(self, instance, field, form, empty_marker=None, emptyReturnsMarker=False):

values = len(instance.getScheduleCriteria())>0 and instance.getScheduleCriteria() or []


if "form.button.save" in form:
value = []
fn = form['fieldName']
Expand Down
5 changes: 1 addition & 4 deletions src/bika/lims/browser/worksheet/views/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class ExportView(BrowserView):
"""
"""
def __call__(self):

translate = self.context.translate

instrument = self.context.getInstrument()
if not instrument:
self.context.plone_utils.addPortalMessage(
Expand Down Expand Up @@ -58,5 +55,5 @@ def __call__(self):
return

exporter = exim.Export(self.context, self.request)
data = exporter(self.context.getAnalyses())
exporter(self.context.getAnalyses())
pass
4 changes: 0 additions & 4 deletions src/bika/lims/content/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,7 @@ def addReferences(self, reference, service_uids):
"""
# TODO Workflow - Analyses. Assignment of refanalysis to Instrument
addedanalyses = []
wf = getToolByName(self, 'portal_workflow')
bsc = getToolByName(self, 'senaite_catalog_setup')
bac = getToolByName(self, 'senaite_catalog_analysis')
ref_type = reference.getBlank() and 'b' or 'c'
ref_uid = reference.UID()
postfix = 1
for refa in reference.getReferenceAnalyses():
grid = refa.getReferenceAnalysesGroupID()
Expand Down
2 changes: 0 additions & 2 deletions src/bika/lims/content/instrumentmaintenancetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from DateTime import DateTime
from Products.Archetypes import atapi
from Products.Archetypes.public import *
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import safe_unicode
from bika.lims import api
from bika.lims import bikaMessageFactory as _
Expand Down Expand Up @@ -170,7 +169,6 @@ def getCurrentStateI18n(self):
return safe_unicode(_(self.getCurrentState()).encode('utf-8'))

def getCurrentState(self):
workflow = getToolByName(self, 'portal_workflow')
if self.getClosed():
return InstrumentMaintenanceTaskStatuses.CLOSED
elif not api.is_active(self):
Expand Down
5 changes: 0 additions & 5 deletions src/bika/lims/vocabularies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Copyright 2018-2021 by it's authors.
# Some rights reserved, see README and LICENSE.

from Acquisition import aq_get
from bika.lims import bikaMessageFactory as _
from bika.lims.api import is_active
from bika.lims.utils import t
Expand Down Expand Up @@ -59,7 +58,6 @@ def __init__(self, context, key=None, value=None, contentFilter=None):

def __call__(self, **kwargs):
site = getSite()
request = aq_get(site, 'REQUEST', None)
catalog = getToolByName(site, self.catalog)
allow_blank = False
if 'allow_blank' in kwargs:
Expand Down Expand Up @@ -106,9 +104,7 @@ def __init__(self, folders, portal_types):

def __call__(self, context):
site = getSite()
request = aq_get(site, 'REQUEST', None)
items = []
wf = site.portal_workflow
for folder in self.folders:
folder = site.restrictedTraverse(folder)
for portal_type in self.portal_types:
Expand Down Expand Up @@ -321,7 +317,6 @@ class ClientContactVocabulary(object):

def __call__(self, context):
site = getSite()
request = aq_get(site, 'REQUEST', None)
items = []
for client in site.clients.objectValues('Client'):
objects = list(client.objectValues('Contact'))
Expand Down
1 change: 0 additions & 1 deletion src/senaite/core/browser/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,6 @@ def _getDateStr(self, period, created):
elif period == PERIODICITY_MONTHLY:
created = '%s-%s' % (str(created.year())[2:], str(created.month()).zfill(2))
elif period == PERIODICITY_WEEKLY:
d = (((created.day()-1)/7)*7)+1
year, weeknum, dow = created.asdatetime().isocalendar()
created = created - dow
created = '%s-%s-%s' % (str(created.year())[2:], str(created.month()).zfill(2), str(created.day()).zfill(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def Import( context, request):
fileformat = request.form['facs_calibur_format']
artoapply = request.form['facs_calibur_artoapply']
override = request.form['facs_calibur_override']
sample = request.form.get('facs_calibur_sample',
'requestid')
instrument = request.form.get('instrument', None)
errors = []
logs = []
Expand Down Expand Up @@ -70,16 +68,6 @@ def Import( context, request):
elif override == 'overrideempty':
over = [True, True]

sam = ['getId', 'getSampleID', 'getClientSampleID']
if sample == 'requestid':
sam = ['getId']
if sample == 'sampleid':
sam = ['getSampleID']
elif sample == 'clientsid':
sam = ['getClientSampleID']
elif sample == 'sample_clientsid':
sam = ['getSampleID', 'getClientSampleID']

importer = FacsCalibur2Importer(parser=parser,
context=context,
allowed_ar_states=status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Export(BrowserView):
def __call__(self, analyses):
tray = 1
now = DateTime().strftime('%Y%m%d-%H%M')
bsc = getToolByName(self.context, 'senaite_catalog_setup')
uc = getToolByName(self.context, 'uid_catalog')
instrument = self.context.getInstrument()
norm = getUtility(IIDNormalizer).normalize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def _addRawResult(self, resid, values={}, override=False):
# First, we must find if already exists a row with results for
# the same date, in order to take into account replicas, Mean
# and Standard Deviation
dtidx = values.get('Calibration',{}).get('Calibration',0)
rows = self.getRawResults().get(resid, [])
row, rows = self._extractrowbycalibration(rows, self._calibration)
is_std = values.get('Rep #',{}).get('Rep #','') == 'Sd'
Expand Down
1 change: 0 additions & 1 deletion src/senaite/core/exportimport/instruments/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def getResultsInputFile(request):

def GenericImport(context, request, parser, importer=None):
infile = getResultsInputFile(request)
fileformat = getFileFormat(request)
artoapply = request.form['artoapply']
override = request.form['results_override']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def parse_resultline(self, line):
# Split by ","
splitted = self.splitLine(line.strip(";"))

errors = ''

# Adjunt separated values from split by ','
for idx, result in enumerate(splitted):
if result.startswith('"'):
Expand Down
9 changes: 1 addition & 8 deletions src/senaite/core/exportimport/setupdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ def Import(self):
class Lab_Products(WorksheetImporter):

def Import(self):
context = self.context
# Refer to the default folder
folder = self.context.bika_setup.bika_labproducts
# Iterate through the rows
Expand Down Expand Up @@ -609,7 +608,7 @@ def Import(self):
password = safe_unicode(row['Password']).encode('utf-8')
if(username):
try:
member = self.context.portal_registration.addMember(
self.context.portal_registration.addMember(
username,
password,
properties={
Expand Down Expand Up @@ -1223,8 +1222,6 @@ class Storage_Locations(WorksheetImporter):

def Import(self):
setup_folder = self.context.bika_setup.bika_storagelocations
bsc = getToolByName(self.context, 'senaite_catalog_setup')
pc = getToolByName(self.context, 'portal_catalog')
for row in self.get_rows(3):
if not row['Address']:
continue
Expand Down Expand Up @@ -1688,7 +1685,6 @@ def resolve_service(self, row):
return service

def Import(self):
s_t = ""
bucket = {}
pc = getToolByName(self.context, "portal_catalog")
bsc = getToolByName(self.context, "senaite_catalog_setup")
Expand Down Expand Up @@ -2156,7 +2152,6 @@ def load_reference_analysis_interims(self, analysis):
if not worksheet:
return
self.interim_worksheet = worksheet
bsc = getToolByName(self.context, 'senaite_catalog_setup')
interims = []
for row in self.get_rows(3, worksheet=self.interim_worksheet):
if row['ReferenceAnalysis_id'] != analysis.getId():
Expand Down Expand Up @@ -2260,8 +2255,6 @@ def load_analysis_interims(self, analysis):
analysis.setInterimFields(interims)

def Import(self):
bc = getToolByName(self.context, 'senaite_catalog')
bsc = getToolByName(self.context, 'senaite_catalog_setup')
pc = getToolByName(self.context, 'portal_catalog')
for row in self.get_rows(3):
if not row['id']:
Expand Down
2 changes: 0 additions & 2 deletions travis_ci_flake8.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ extend-ignore =
F812,
# F821: undefined name 'Report'
F821,
# F841: local variable 'icon' is assigned to but never used
F841,
# F901: 'raise NotImplemented' should be 'raise NotImplementedError'
F901,
# W191: indentation contains tabs
Expand Down