From 3fb6bef1a4e6f1625563349dfc4b5ac7d054dfd2 Mon Sep 17 00:00:00 2001 From: Emilio Mayorga Date: Sat, 20 Apr 2019 14:26:02 -0700 Subject: [PATCH 1/3] coding standards improvements, per Travis CI results --- odm2api/services/readService.py | 32 ++++++++++++++--------------- tests/test_odm2/test_readservice.py | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/odm2api/services/readService.py b/odm2api/services/readService.py index e93a712..9d537f3 100644 --- a/odm2api/services/readService.py +++ b/odm2api/services/readService.py @@ -185,7 +185,7 @@ def getAnnotations(self, annottype=None, codes=None, ids=None, **kwargs): a = Annotations self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the annottype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the annottype parameter instead.", DeprecationWarning, stacklevel=2) annottype = kwargs['type'] if annottype: @@ -238,7 +238,7 @@ def getCVs(self, cvtype, **kwargs): """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the cvtype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the cvtype parameter instead.", DeprecationWarning, stacklevel=2) cvtype = kwargs['type'] @@ -430,7 +430,7 @@ def getMethods(self, ids=None, codes=None, methodtype=None, **kwargs): """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the medtype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the medtype parameter instead.", DeprecationWarning, stacklevel=2) methodtype = kwargs['type'] @@ -517,7 +517,7 @@ def getSamplingFeatures(self, ids=None, codes=None, uuids=None, """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the sftype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the sftype parameter instead.", DeprecationWarning, stacklevel=2) sftype = kwargs['type'] if results: @@ -591,7 +591,7 @@ def getActions(self, ids=None, acttype=None, sfid=None, **kwargs): """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the acttype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the acttype parameter instead.", DeprecationWarning, stacklevel=2) acttype = kwargs['type'] a = Actions @@ -641,7 +641,7 @@ def getUnits(self, ids=None, name=None, unittype=None, **kwargs): """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the unittype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the unittype parameter instead.", DeprecationWarning, stacklevel=2) unittype = kwargs['type'] q = self._session.query(Units) @@ -779,7 +779,7 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati query = self._session.query(Results) self._check_kwargs(['type', 'sfid'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the restype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the restype parameter instead.", DeprecationWarning, stacklevel=2) restype = kwargs['type'] if restype: @@ -798,8 +798,8 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati if actionid: query = query.join(FeatureActions).filter_by(ActionID=actionid) if 'sfid' in kwargs: - warnings.warn('The parameter \'sfid\' is deprecated. ' - 'Please use the sfids parameter instead and send in a list.', + warnings.warn("The parameter 'sfid' is deprecated. " + "Please use the sfids parameter instead and send in a list.", DeprecationWarning, stacklevel=2) if kwargs['sfid']: query = query.join(FeatureActions).filter_by(SamplingFeatureID=kwargs['sfid']) @@ -1087,7 +1087,7 @@ def getEquipment(self, codes=None, equiptype=None, sfid=None, actionid=None, **k """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the equiptype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the equiptype parameter instead.", DeprecationWarning, stacklevel=2) equiptype = kwargs['type'] @@ -1191,7 +1191,7 @@ def getExtensionProperties(self, exptype=None, **kwargs): # Todo what values to use for extensionproperties type self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the exptype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the exptype parameter instead.", DeprecationWarning, stacklevel=2) exptype = kwargs['type'] e = ExtensionProperties @@ -1222,7 +1222,7 @@ def getExternalIdentifiers(self, eitype=None, **kwargs): """ self._check_kwargs(['type'], kwargs) if 'type' in kwargs: - warnings.warn('The parameter \'type\' is deprecated. Please use the eitype parameter instead.', + warnings.warn("The parameter 'type' is deprecated. Please use the eitype parameter instead.", DeprecationWarning, stacklevel=2) eitype = kwargs['type'] e = ExternalIdentifierSystems @@ -1415,9 +1415,9 @@ def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=Tru df.columns = [self._get_columns(ResultValues)[c] for c in df.columns] else: warnings.warn( - 'In a near-future release, ' - 'the parameter \'lowercols\' default will be changed to False, ' - 'and later the parameter may be removed.', + "In a near-future release, " + "the parameter 'lowercols' default will be changed to False, " + "and later the parameter may be removed.", DeprecationWarning, stacklevel=2) return df except Exception as e: @@ -1487,7 +1487,7 @@ def getRelatedModels(self, modid=None, code=None, **kwargs): """ self._check_kwargs(['id'], kwargs) if 'id' in kwargs: - warnings.warn('The parameter \'id\' is deprecated. Please use the modid parameter instead.', + warnings.warn("The parameter 'id' is deprecated. Please use the modid parameter instead.", DeprecationWarning, stacklevel=2) modid = kwargs['id'] m = self._session.query(Models).select_from(RelatedModels).join(RelatedModels.ModelObj) diff --git a/tests/test_odm2/test_readservice.py b/tests/test_odm2/test_readservice.py index 3e7189f..814531c 100644 --- a/tests/test_odm2/test_readservice.py +++ b/tests/test_odm2/test_readservice.py @@ -3,8 +3,8 @@ from os.path import abspath, dirname, join from odm2api import models -from odm2api.services.readService import ReadODM2 from odm2api.ODMconnection import dbconnection +from odm2api.services.readService import ReadODM2 import pytest From 60bfd180f9673aedf7d78a1ed2f1a179e1a61691 Mon Sep 17 00:00:00 2001 From: Emilio Mayorga Date: Sat, 20 Apr 2019 14:41:41 -0700 Subject: [PATCH 2/3] Additional coding standard fix (bad quotes) --- odm2api/services/readService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odm2api/services/readService.py b/odm2api/services/readService.py index 9d537f3..896307b 100644 --- a/odm2api/services/readService.py +++ b/odm2api/services/readService.py @@ -798,7 +798,7 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati if actionid: query = query.join(FeatureActions).filter_by(ActionID=actionid) if 'sfid' in kwargs: - warnings.warn("The parameter 'sfid' is deprecated. " + warnings.warn("The parameter 'sfid' is deprecated. " + "Please use the sfids parameter instead and send in a list.", DeprecationWarning, stacklevel=2) if kwargs['sfid']: @@ -1415,8 +1415,8 @@ def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=Tru df.columns = [self._get_columns(ResultValues)[c] for c in df.columns] else: warnings.warn( - "In a near-future release, " - "the parameter 'lowercols' default will be changed to False, " + "In a near-future release, " + + "the parameter 'lowercols' default will be changed to False, " + "and later the parameter may be removed.", DeprecationWarning, stacklevel=2) return df From 6dfe5905751d88102343a6cc091f4e141e7b1fef Mon Sep 17 00:00:00 2001 From: Emilio Mayorga Date: Sat, 20 Apr 2019 15:11:26 -0700 Subject: [PATCH 3/3] Add # noqa to handle flake8 bad quotes --- odm2api/services/readService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odm2api/services/readService.py b/odm2api/services/readService.py index 896307b..3a04043 100644 --- a/odm2api/services/readService.py +++ b/odm2api/services/readService.py @@ -799,7 +799,7 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati query = query.join(FeatureActions).filter_by(ActionID=actionid) if 'sfid' in kwargs: warnings.warn("The parameter 'sfid' is deprecated. " + - "Please use the sfids parameter instead and send in a list.", + "Please use the sfids parameter instead and send in a list.", # noqa DeprecationWarning, stacklevel=2) if kwargs['sfid']: query = query.join(FeatureActions).filter_by(SamplingFeatureID=kwargs['sfid']) @@ -1415,9 +1415,9 @@ def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=Tru df.columns = [self._get_columns(ResultValues)[c] for c in df.columns] else: warnings.warn( - "In a near-future release, " + + "In a near-future release, " + # noqa "the parameter 'lowercols' default will be changed to False, " + - "and later the parameter may be removed.", + "and later the parameter may be removed.", # noqa DeprecationWarning, stacklevel=2) return df except Exception as e: