Skip to content

Commit

Permalink
Use different version for pylint-django for python 2 and 3
Browse files Browse the repository at this point in the history
Starting from `pylint-django>=2.0` only `pylint>=2.0` is supported which
has dropped support for python 2. As a result we need to depend on
different version of `pylint-django` based on the version of python.

With the new version of `pylint` a lot of new checks are added that had
to be either corrected or disabled. Given that some of these checks only
are valid for `pylint>=2.0`, they will trigger a warning in the
pre-commit for python 2. For this reason we have to temporarily disable
the `bad-option-value` globally in the `.pylintrc`. When support for
python 2 is dropped, this should be removed.
  • Loading branch information
sphuber committed Jan 4, 2019
1 parent 616f0d8 commit 6424ba1
Show file tree
Hide file tree
Showing 123 changed files with 233 additions and 384 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=bad-continuation,locally-disabled,useless-suppression,django-not-available
disable=bad-continuation,locally-disabled,useless-suppression,django-not-available,bad-option-value

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def detect_unexpected_links(apps, schema_editor):

def reverse_code(apps, schema_editor):
"""Reversing the inference of the process type is not possible and not necessary."""
pass


class Migration(migrations.Migration):
Expand Down
1 change: 1 addition & 0 deletions aiida/backends/djsite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def check_schema_version(profile_name=None):
:raise ConfigurationError: if the two schema versions do not match.
Otherwise, just return.
"""
# pylint: disable=duplicate-string-formatting-argument
from django.db import connection

import aiida.backends.djsite.db.models
Expand Down
2 changes: 1 addition & 1 deletion aiida/backends/tests/common/test_hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_numpy_arrays(self):

def test_unhashable_type(self):

class MadeupClass(object):
class MadeupClass(object): # pylint: disable=useless-object-inheritance
pass

with self.assertRaises(ValueError):
Expand Down
6 changes: 3 additions & 3 deletions aiida/backends/tests/orm/node/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_node_indegree_unique_pair(self):
called.add_incoming(data, link_type=LinkType.INPUT_CALC, link_label='call')
called.store()

uuids_incoming = set([node.uuid for node in called.get_incoming().all_nodes()])
uuids_incoming = set(node.uuid for node in called.get_incoming().all_nodes())
uuids_expected = set([caller.uuid, data.uuid])
self.assertEqual(uuids_incoming, uuids_expected)

Expand All @@ -232,7 +232,7 @@ def test_node_indegree_unique_triple(self):
data.add_incoming(return_two, link_type=LinkType.RETURN, link_label='return')
data.store()

uuids_incoming = set([node.uuid for node in data.get_incoming().all_nodes()])
uuids_incoming = set(node.uuid for node in data.get_incoming().all_nodes())
uuids_expected = set([return_one.uuid, return_two.uuid])
self.assertEqual(uuids_incoming, uuids_expected)

Expand All @@ -253,6 +253,6 @@ def test_node_outdegree_unique_triple(self):
data_one.store()
data_two.store()

uuids_outgoing = set([node.uuid for node in creator.get_outgoing().all_nodes()])
uuids_outgoing = set(node.uuid for node in creator.get_outgoing().all_nodes())
uuids_expected = set([data_one.uuid, data_two.uuid])
self.assertEqual(uuids_outgoing, uuids_expected)
2 changes: 0 additions & 2 deletions aiida/backends/tests/restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ def test_computers_orderby_mixed3(self):
-hostname",
expected_list_ids=[1,0,4,3,2])
"""
pass

############### list filter combinations #######################
def test_computers_filter_mixed1(self):
Expand Down Expand Up @@ -675,7 +674,6 @@ def test_computers_unknown_param(self):
from aiida.common.exceptions import InputValidationError
RESTApiTestCase.node_exception(self, "/computers?aa=bb&id=2", InputValidationError)
"""
pass

############### single calculation ########################
def test_calculations_details(self):
Expand Down
2 changes: 1 addition & 1 deletion aiida/calculations/plugins/arithmetic/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _use_methods(cls):

def _get_input_valid_types(self, key):
"""Return the valid input types for the given key."""
return self._use_methods[key]['valid_types']
return self._use_methods[key]['valid_types'] # pylint: disable=unsubscriptable-object

def _get_input_valid_type(self, key):
"""Return the valid input type for the given key."""
Expand Down
2 changes: 1 addition & 1 deletion aiida/calculations/plugins/templatereplacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _prepare_for_submission(self, tempfolder, inputdict):
:param inputdict: a dictionary with the input nodes e.g. {label1: node1, ...} (with the Code!)
"""
# pylint: disable=too-many-locals,too-many-statements,too-many-branches
from six.moves import StringIO as StringIO
from six.moves import StringIO

from aiida.orm.data.singlefile import SinglefileData
from aiida.orm.data.remote import RemoteData
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_calcjob.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@verdi.group('calcjob')
def verdi_calcjob():
"""Inspect and manage calcjobs."""
pass


@verdi_calcjob.command('gotocomputer')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@verdi.group('calculation')
def verdi_calculation():
"""Inspect and manage calculations."""
pass


@verdi_calculation.command('gotocomputer')
Expand Down
2 changes: 0 additions & 2 deletions aiida/cmdline/commands/cmd_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@verdi.group('code')
def verdi_code():
"""Setup and manage codes."""
pass


def get_default(key, ctx):
Expand Down Expand Up @@ -215,7 +214,6 @@ def reveal(codes):
# pylint: disable=unused-argument
def update(code):
"""Update an existing code."""
pass


@verdi_code.command()
Expand Down
3 changes: 1 addition & 2 deletions aiida/cmdline/commands/cmd_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@verdi.group('comment')
def verdi_comment():
"""Inspect, create and manage node comments."""
pass


@verdi_comment.command()
Expand Down Expand Up @@ -76,7 +75,7 @@ def show(user, nodes):
comments = [comment for comment in all_comments if comment.user.email == user.email]

if not comments:
valid_users = ', '.join(set([comment.user.email for comment in all_comments]))
valid_users = ', '.join(set(comment.user.email for comment in all_comments))
echo.echo_warning('no comments found for user {}'.format(user))
echo.echo_info('valid users found for Node<{}>: {}'.format(node.pk, valid_users))

Expand Down
10 changes: 4 additions & 6 deletions aiida/cmdline/commands/cmd_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
@verdi.group('computer')
def verdi_computer():
"""Setup and manage computers."""
pass


def get_computer_names():
Expand Down Expand Up @@ -161,8 +160,8 @@ def _computer_create_temp_file(transport, scheduler, authinfo): # pylint: disab
if not transport.path_exists(remote_file_path):
echo.echo_error("* ERROR! The file was not found!")
return False
else:
echo.echo(" [OK]")

echo.echo(" [OK]")
echo.echo(" `-> Retrieving the file and checking its content...")

handle, destfile = tempfile.mkstemp()
Expand All @@ -179,8 +178,8 @@ def _computer_create_temp_file(transport, scheduler, authinfo): # pylint: disab
echo.echo("** Found:")
echo.echo(read_string)
return False
else:
echo.echo(" [Content OK]")

echo.echo(" [Content OK]")
finally:
os.remove(destfile)

Expand Down Expand Up @@ -621,7 +620,6 @@ def computer_delete(computer):
@verdi_computer.group('configure')
def computer_configure():
"""Configure a computer with one of the available transport types."""
pass


@computer_configure.command('show')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
@verdi.group('daemon')
def verdi_daemon():
"""Inspect and manage the daemon."""
pass


@verdi_daemon.command()
Expand Down
3 changes: 1 addition & 2 deletions aiida/cmdline/commands/cmd_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@

from aiida.cmdline.commands.cmd_verdi import verdi
from aiida.cmdline.commands.cmd_plugin import verdi_plugin
from aiida.cmdline.utils import decorators, echo
from aiida.cmdline.utils import decorators
from aiida.cmdline.utils.pluginable import Pluginable


@verdi.group('data', entry_point_group='aiida.cmdline.data', cls=Pluginable)
def verdi_data():
"""Inspect, create and manage data nodes."""
pass


@verdi_data.command('plugins')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@verdi_data.group('array')
def array():
"""Manipulate ArrayData objects."""
pass


@array.command('show')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@verdi_data.group('bands')
def bands():
"""Manipulate BandsData objects."""
pass


# pylint: disable=too-many-arguments
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@verdi_data.group('cif')
def cif():
"""Manipulation of CIF data objects."""
pass


@cif.command('list')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@verdi_data.group('parameter')
def parameter():
"""View and manipulate ParameterData objects."""
pass


@parameter.command('show')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
@verdi_data.group('remote')
def remote():
"""Managing RemoteData objects."""
pass


@remote.command('ls')
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/commands/cmd_data/cmd_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _show_ase(exec_name, structure_list):
from ase.visualize import view
for structure in structure_list:
view(structure.get_ase())
except ImportError:
except ImportError: # pylint: disable=try-except-raise
raise


Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
@verdi_data.group('structure')
def structure():
"""Manipulation of StructureData objects."""
pass


# pylint: disable=too-many-locals,too-many-branches
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
@verdi_data.group('trajectory')
def trajectory():
"""View and manipulate TrajectoryData instances."""
pass


@trajectory.command('list')
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_data/cmd_upf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@verdi_data.group('upf')
def upf():
"""Manipulation of the upf families."""
pass


@upf.command('uploadfamily')
Expand Down
2 changes: 0 additions & 2 deletions aiida/cmdline/commands/cmd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
@verdi.group('database')
def verdi_database():
"""Inspect and manage the database."""
pass


@verdi_database.command('migrate')
Expand All @@ -48,7 +47,6 @@ def database_migrate(force):
@verdi_database.group('integrity')
def verdi_database_integrity():
"""Various commands that will check the integrity of the database and fix potential issues when asked."""
pass


@verdi_database_integrity.command('detect-duplicate-node-uuid')
Expand Down
3 changes: 1 addition & 2 deletions aiida/cmdline/commands/cmd_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@verdi.group('devel')
def verdi_devel():
"""Commands for developers."""
pass


def get_valid_test_paths():
Expand Down Expand Up @@ -156,7 +155,7 @@ def devel_tests(paths, verbose): # pylint: disable=too-many-locals,too-many-sta
echo.echo('* Tests skipped: {}'.format(len(test_skipped)))
if test_skipped:
echo.echo(' Reasons for skipping:')
for reason in sorted(set([_[1] for _ in test_skipped])):
for reason in sorted(set(_[1] for _ in test_skipped)):
echo.echo(' - {}'.format(reason))

echo.echo('* Tests run: {}'.format(tot_num_tests))
Expand Down
13 changes: 5 additions & 8 deletions aiida/cmdline/commands/cmd_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
@verdi.group('export')
def verdi_export():
"""Create and manage export archives."""
pass


@verdi_export.command('inspect')
Expand Down Expand Up @@ -202,7 +201,7 @@ def migrate(input_file, output_file, force, silent, archive_format):
with io.open(folder.get_abs_path('metadata.json'), 'wb') as fhandle:
json.dump(metadata, fhandle)

if archive_format == 'zip' or archive_format == 'zip-uncompressed':
if archive_format in ['zip', 'zip-uncompressed']:
compression = zipfile.ZIP_DEFLATED if archive_format == 'zip' else zipfile.ZIP_STORED
with zipfile.ZipFile(output_file, mode='w', compression=compression, allowZip64=True) as archive:
src = folder.abspath
Expand Down Expand Up @@ -280,7 +279,7 @@ def migrate_v1_to_v2(metadata, data):
try:
verify_metadata_version(metadata, old_version)
update_metadata(metadata, new_version)
except ValueError:
except ValueError: # pylint: disable=try-except-raise
raise

def get_new_string(old_string):
Expand Down Expand Up @@ -364,7 +363,7 @@ class NodeType(enum.Enum): # pylint: disable=too-few-public-methods
try:
verify_metadata_version(metadata, old_version)
update_metadata(metadata, new_version)
except ValueError:
except ValueError: # pylint: disable=try-except-raise
raise

# Create a mapping from node uuid to node type
Expand Down Expand Up @@ -407,15 +406,13 @@ class NodeType(enum.Enum): # pylint: disable=too-few-public-methods
# (CALC) -> (DATA) : CREATE
# (WORK) -> (DATA) : RETURN
# (WORK) -> (CALC, WORK) : CALL
if (input_type == NodeType.CODE or input_type == NodeType.DATA) \
and (output_type == NodeType.CALC or output_type == NodeType.WORK):
if input_type in [NodeType.CODE, NodeType.DATA] and output_type in [NodeType.CALC, NodeType.WORK]:
link['type'] = LinkType.INPUT.value
elif input_type == NodeType.CALC and output_type == NodeType.DATA:
link['type'] = LinkType.CREATE.value
elif input_type == NodeType.WORK and output_type == NodeType.DATA:
link['type'] = LinkType.RETURN.value
elif input_type == NodeType.WORK \
and (output_type == NodeType.CALC or output_type == NodeType.WORK):
elif input_type == NodeType.WORK and output_type in [NodeType.CALC, NodeType.WORK]:
link['type'] = LinkType.CALL.value
else:
link['type'] = LinkType.UNSPECIFIED.value
Expand Down
1 change: 0 additions & 1 deletion aiida/cmdline/commands/cmd_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def verdi_graph():
Create visual representations of part of the provenance graph.
Requires that `graphviz<https://graphviz.org/download>` be installed.
"""
pass


@verdi_graph.command('generate')
Expand Down
9 changes: 2 additions & 7 deletions aiida/cmdline/commands/cmd_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@verdi.group('group')
def verdi_group():
"""Inspect, create and manage groups."""
pass


@verdi_group.command("removenodes")
Expand Down Expand Up @@ -332,9 +331,5 @@ def group_copy(source_group, destination_group):

dest_group = orm.Group.objects.get_or_create(
label=destination_group, type_string=GroupTypeString(source_group.type_string))[0]
try:
dest_group.add_nodes(source_group.nodes)
echo.echo_success("Nodes were succesfully copied from the group <{}> to the group "
"<{}>".format(source_group, destination_group))
except:
raise
dest_group.add_nodes(source_group.nodes)
echo.echo_success("Nodes copied from group<{}> to group<{}>".format(source_group, destination_group))
Loading

0 comments on commit 6424ba1

Please sign in to comment.