Skip to content

Commit

Permalink
Update Pylint 2.0+ (#266)
Browse files Browse the repository at this point in the history
This updates Pylint to 2.0+ and fixes all the associated code with
that gets affected.

Signed-off-by: David Brown <dmlb2000@gmail.com>
  • Loading branch information
dmlb2000 committed Dec 18, 2019
1 parent 532960a commit aa4e548
Show file tree
Hide file tree
Showing 71 changed files with 144 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: autopep8
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
rev: v2.4.0
hooks:
- id: fix-encoding-pragma
- id: trailing-whitespace
Expand Down Expand Up @@ -49,7 +49,7 @@ repos:
language: system
types: [python]
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.6
rev: v1.1.7
hooks:
- id: remove-tabs
- id: remove-crlf
34 changes: 14 additions & 20 deletions pacifica/metadata/client.py
Expand Up @@ -8,10 +8,8 @@
class PMClientError(Exception):
"""Base Exception Error Class."""

pass


class PMClient(object):
class PMClient:
"""
Pacifica Metadata Client.
Expand All @@ -30,12 +28,11 @@ def create(self, cls_type, set_hash):
data=dumps(set_hash), headers=self.headers)
if int(ret.status_code / 100) == 2:
return True
elif int(ret.status_code / 100) == 5:
if int(ret.status_code / 100) == 5:
raise PMClientError('Internal Server Error ({0}) {1}'.format(
ret.status_code, ret.content))
else:
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))

def update(self, cls_type, query_hash, set_hash):
"""
Expand All @@ -52,37 +49,34 @@ def update(self, cls_type, query_hash, set_hash):
return True
if int(ret.status_code / 100) == 4:
return False
elif int(ret.status_code / 100) == 5:
if int(ret.status_code / 100) == 5:
raise PMClientError('Internal Server Error ({0}) {1}'.format(
ret.status_code, ret.content))
else:
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))

def get(self, cls_type, query_hash):
"""Get the object of type from query_hash."""
ret = requests.get('{0}/{1}'.format(self.url, cls_type),
params=query_hash, allow_redirects=True)
if int(ret.status_code / 100) == 2:
return loads(ret.content.decode('UTF-8'))
elif int(ret.status_code / 100) == 4:
if int(ret.status_code / 100) == 4:
return {}
elif int(ret.status_code / 100) == 5:
if int(ret.status_code / 100) == 5:
raise PMClientError('Internal Server Error ({0}) {1}'.format(
ret.status_code, ret.content))
else:
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))

def delete(self, cls_type, query_hash):
"""Delete the object of type from query_hash."""
ret = requests.delete(
'{0}/{1}'.format(self.url, cls_type), params=query_hash, allow_redirects=True)
if int(ret.status_code / 100) == 2 or int(ret.status_code / 100) == 4:
return True
elif int(ret.status_code / 100) == 5:
if int(ret.status_code / 100) == 5:
raise PMClientError('Internal Server Error ({0}) {1}'.format(
ret.status_code, ret.content))
else:
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))
raise PMClientError('Unknown Error ({0}) {1}'.format(
ret.status_code, ret.content))
5 changes: 1 addition & 4 deletions pacifica/metadata/config.py
Expand Up @@ -3,10 +3,7 @@
"""Configuration reading and validation module."""
import logging
from os import getenv
try:
from ConfigParser import SafeConfigParser
except ImportError: # pragma: no cover python 2 vs 3 issue
from configparser import ConfigParser as SafeConfigParser
from configparser import ConfigParser as SafeConfigParser
from pacifica.metadata.globals import CONFIG_FILE


Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/atool_project.py
Expand Up @@ -27,7 +27,7 @@ class AToolProject(CherryPyAPI):
analytical_tool = ForeignKeyField(AnalyticalTools, backref='projects')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/atool_transaction.py
Expand Up @@ -27,7 +27,7 @@ class AToolTransaction(CherryPyAPI):
analytical_tool = ForeignKeyField(AnalyticalTools, backref='transactions')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/base.py
Expand Up @@ -67,7 +67,7 @@ class PacificaModel(Model):
deleted = ExtendDateTimeField(null=True, index=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the db connection."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/citation_contributor.py
Expand Up @@ -30,7 +30,7 @@ class CitationContributor(CherryPyAPI):
author_precedence = IntegerField(default=1)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains database and primary keys."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/citation_doi.py
Expand Up @@ -27,7 +27,7 @@ class CitationDOI(CherryPyAPI):
citation = ForeignKeyField(Citations, backref='doi_entries')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/citation_keyword.py
Expand Up @@ -27,7 +27,7 @@ class CitationKeyword(CherryPyAPI):
keyword = ForeignKeyField(Keywords, backref='citations')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/citation_project.py
Expand Up @@ -27,7 +27,7 @@ class CitationProject(CherryPyAPI):
project = ForeignKeyField(Projects, backref='citations')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/citation_transaction.py
Expand Up @@ -27,7 +27,7 @@ class CitationTransaction(CherryPyAPI):
transaction = ForeignKeyField(TransactionUser, backref='citations')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/dataset_file.py
Expand Up @@ -27,7 +27,7 @@ class DatasetFile(CherryPyAPI):
file = ForeignKeyField(Files, backref='files')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/dataset_project_user.py
Expand Up @@ -37,7 +37,7 @@ class DatasetProjectUser(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='dataset_project_user')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/doi_author_mapping.py
Expand Up @@ -30,7 +30,7 @@ class DOIAuthorMapping(CherryPyAPI):
author_order = IntegerField(default=1)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/doi_info.py
Expand Up @@ -30,7 +30,7 @@ class DOIInfo(CherryPyAPI):
value = CharField()

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/file_key_value.py
Expand Up @@ -31,7 +31,7 @@ class FileKeyValue(CherryPyAPI):
value = ForeignKeyField(Values, backref='file_links')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/institution_user.py
Expand Up @@ -32,7 +32,7 @@ class InstitutionUser(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='institution_user')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/instrument_data_source.py
Expand Up @@ -32,7 +32,7 @@ class InstrumentDataSource(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='instrument_data_source')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/instrument_group.py
Expand Up @@ -27,7 +27,7 @@ class InstrumentGroup(CherryPyAPI):
group = ForeignKeyField(Groups, backref='instrument_members')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/instrument_key_value.py
Expand Up @@ -35,7 +35,7 @@ class InstrumentKeyValue(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='instrument_kvp')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/instrument_user.py
Expand Up @@ -32,7 +32,7 @@ class InstrumentUser(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='instrument_user')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/project_group.py
Expand Up @@ -27,7 +27,7 @@ class ProjectGroup(CherryPyAPI):
project = ForeignKeyField(Projects, backref='groups')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/project_instrument.py
Expand Up @@ -33,7 +33,7 @@ class ProjectInstrument(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='relationship')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/project_user.py
Expand Up @@ -33,7 +33,7 @@ class ProjectUser(CherryPyAPI):
relationship = ForeignKeyField(Relationships, backref='project_user')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
4 changes: 2 additions & 2 deletions pacifica/metadata/orm/sync.py
Expand Up @@ -15,7 +15,7 @@
# pylint: disable=too-few-public-methods


class OrmSync(object):
class OrmSync:
"""
Special module for syncing the orm.
Expand Down Expand Up @@ -147,7 +147,7 @@ class MetadataSystem(Model):
part = CharField(primary_key=True)
value = IntegerField(default=-1)

class Meta(object):
class Meta:
"""Meta object containing the database connection."""

database = DB # This model uses the pacifica_cart database.
Expand Down
8 changes: 4 additions & 4 deletions pacifica/metadata/orm/sync_updates/update_0_1_to_1_0.py
Expand Up @@ -13,7 +13,7 @@ class OldProposals(Model):
id = CharField(primary_key=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""This is the meta class for OldTrans."""

database = DB
Expand All @@ -33,7 +33,7 @@ class OldTrans(Model):
deleted = DateTimeField(null=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""This is the meta class for OldTrans."""

database = DB
Expand All @@ -57,7 +57,7 @@ class OldTransSIP(Model):
deleted = DateTimeField(null=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""This is the meta class for OldTrans."""

database = DB
Expand All @@ -81,7 +81,7 @@ class OldTransSAP(Model):
deleted = DateTimeField(null=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""This is the meta class for OldTrans."""

database = DB
Expand Down
6 changes: 3 additions & 3 deletions pacifica/metadata/orm/sync_updates/update_2_1_to_3_0.py
Expand Up @@ -65,7 +65,7 @@ class OldInstKeyValue(Model):
deleted = DateTimeField(index=True, null=True)

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down Expand Up @@ -97,7 +97,7 @@ def _add_relationship_columns():
migrator.rename_column('doitransaction', 'transaction_id', 'trans_old_id')
)
for table_name, rel_info in table_rel.items():
DB.execute_sql('alter table {} drop constraint {}_pkey'.format(table_name, table_name))
DB.execute_sql('alter table {0} drop constraint {0}_pkey'.format(table_name))
rel_name, backref, pkey_columns = rel_info
rel_obj = Relationships.get(Relationships.name == rel_name)
migrate(
Expand All @@ -122,7 +122,7 @@ def _add_relationship_columns():
condition.append(u'{} = {}'.format(key, param_val))
condition = u' and '.join(condition)
DB.execute_sql(u'update {} set uuid = %s where {}'.format(table_name, condition), (str(uuid.uuid4()),))
DB.execute_sql('alter table {} add constraint {}_pkey primary key (uuid)'.format(table_name, table_name))
DB.execute_sql('alter table {0} add constraint {0}_pkey primary key (uuid)'.format(table_name))
migrate(
migrator.add_column(
'citationtransaction', 'transaction_id',
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/sync_updates/update_6_0_to_7_0.py
Expand Up @@ -16,7 +16,7 @@ class OldRelationships(Model):
description = TextField(default='')
encoding = CharField(default='UTF8')

class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down
2 changes: 1 addition & 1 deletion pacifica/metadata/orm/trans_key_value.py
Expand Up @@ -31,7 +31,7 @@ class TransactionKeyValue(CherryPyAPI):
value = ForeignKeyField(Values, backref='trans_links')

# pylint: disable=too-few-public-methods
class Meta(object):
class Meta:
"""PeeWee meta class contains the database and the primary key."""

database = DB
Expand Down

0 comments on commit aa4e548

Please sign in to comment.