Skip to content

Commit

Permalink
Drop Python2 support. (#95)
Browse files Browse the repository at this point in the history
* Remove python2 things from setup.json.

* Remove all `from __future__ ...` statements.

* Remove `modernizer` hook from the pre-commit config.

* Remove `six` and all the references in the code.
  • Loading branch information
yakutovicha committed Mar 30, 2020
1 parent bb9f2a9 commit ed80b8c
Show file tree
Hide file tree
Showing 28 changed files with 29 additions and 110 deletions.
2 changes: 0 additions & 2 deletions .ci/check_travis_tag.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Check travis tag"""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
Expand Down
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
@@ -1,17 +1,6 @@
# # Install pre-commit hooks via
# pre-commit install

# modernizer: make sure our code-base is Python 3 ready
- repo: https://github.com/python-modernize/python-modernize.git
sha: a234ce4e185cf77a55632888f1811d83b4ad9ef2
hooks:
- id: python-modernize
exclude: ^docs/
args:
- --write
- --nobackups
- --nofix=dict_six

- repo: local
hooks:
# yapf = yet another python formatter
Expand Down
4 changes: 0 additions & 4 deletions .pylintrc
Expand Up @@ -273,10 +273,6 @@ ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins


[MISCELLANEOUS]

Expand Down
15 changes: 4 additions & 11 deletions aiida_cp2k/calculations/__init__.py
Expand Up @@ -7,11 +7,7 @@
###############################################################################
"""AiiDA-CP2K input plugin."""

from __future__ import absolute_import

import io
import six
from six.moves import map

from aiida.engine import CalcJob
from aiida.orm import Computer, Dict, SinglefileData, StructureData, RemoteData, BandsData
Expand Down Expand Up @@ -51,16 +47,13 @@ def define(cls, spec):
dynamic=True)

# Specify default parser.
spec.input('metadata.options.parser_name',
valid_type=six.string_types,
default=cls._DEFAULT_PARSER,
non_db=True)
spec.input('metadata.options.parser_name', valid_type=str, default=cls._DEFAULT_PARSER, non_db=True)

# Add input_filename attribute.
spec.input('metadata.options.input_filename', valid_type=six.string_types, default=cls._DEFAULT_INPUT_FILE)
spec.input('metadata.options.input_filename', valid_type=str, default=cls._DEFAULT_INPUT_FILE)

# Add output_filename attribute.
spec.input('metadata.options.output_filename', valid_type=six.string_types, default=cls._DEFAULT_OUTPUT_FILE)
spec.input('metadata.options.output_filename', valid_type=str, default=cls._DEFAULT_OUTPUT_FILE)

# Use mpi by default.
spec.input('metadata.options.withmpi', valid_type=bool, default=True)
Expand Down Expand Up @@ -129,7 +122,7 @@ def prepare_for_submission(self, folder):
try:
fobj.write(inp.render())
except ValueError as exc:
six.raise_from(InputValidationError("invalid keys or values in input parameters found"), exc)
raise InputValidationError("Invalid keys or values in input parameters found") from exc

settings = self.inputs.settings.get_dict() if 'settings' in self.inputs else {}

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/parsers/__init__.py
Expand Up @@ -6,7 +6,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""AiiDA-CP2K output parser."""
from __future__ import absolute_import

import io
import os
Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/utils/__init__.py
Expand Up @@ -6,7 +6,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""AiiDA-CP2K utils"""
from __future__ import absolute_import

from .input_generator import Cp2kInput
from .parser import parse_cp2k_output
Expand Down
15 changes: 4 additions & 11 deletions aiida_cp2k/utils/input_generator.py
Expand Up @@ -7,16 +7,9 @@
###############################################################################
"""AiiDA-CP2K input generator"""

from __future__ import absolute_import
from __future__ import division

from copy import deepcopy

import six
if six.PY2:
from collections import Mapping, Sequence # pylint: disable=import-error, no-name-in-module
else:
from collections.abc import Mapping, Sequence # pylint: disable=import-error, no-name-in-module
from collections.abc import Mapping, Sequence


class Cp2kInput: # pylint: disable=old-style-class
Expand Down Expand Up @@ -55,7 +48,7 @@ def add_keyword(self, kwpath, value, override=True, conflicting_keys=None):
added.
"""

if isinstance(kwpath, six.string_types):
if isinstance(kwpath, str):
kwpath = kwpath.split("/")

Cp2kInput._add_keyword(kwpath, value, self._params, ovrd=override, cfct=conflicting_keys)
Expand Down Expand Up @@ -89,7 +82,7 @@ def _add_keyword(kwpath, value, params, ovrd, cfct):
Cp2kInput._add_keyword(kwpath[1:], value, params[kwpath[0]], ovrd, cfct)

# if it is a list, loop over its elements
elif isinstance(params[kwpath[0]], Sequence) and not isinstance(params[kwpath[0]], six.string_types):
elif isinstance(params[kwpath[0]], Sequence) and not isinstance(params[kwpath[0]], str):
for element in params[kwpath[0]]:
Cp2kInput._add_keyword(kwpath[1:], value, element, ovrd, cfct)

Expand Down Expand Up @@ -151,7 +144,7 @@ def _render_section(output, params, indent=0):
Cp2kInput._render_section(output, val, indent + 3)
output.append('{}&END {}'.format(' ' * indent, key))

elif isinstance(val, Sequence) and not isinstance(val, six.string_types):
elif isinstance(val, Sequence) and not isinstance(val, str):
for listitem in val:
Cp2kInput._render_section(output, {key: listitem}, indent)

Expand Down
3 changes: 0 additions & 3 deletions aiida_cp2k/utils/parser.py
Expand Up @@ -7,9 +7,6 @@
###############################################################################
"""AiiDA-CP2K input plugin."""

from __future__ import absolute_import
from __future__ import division

import re
import math

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/utils/workchains.py
Expand Up @@ -7,7 +7,6 @@
###############################################################################
"""AiiDA-CP2K utilities for workchains"""

from __future__ import absolute_import
from aiida.engine import calcfunction
from aiida.orm import Dict, StructureData

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/workchains/aiida_base_restart.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
# pylint: disable=inconsistent-return-statements,no-member
"""Base implementation of `WorkChain` class that implements a simple automated restart mechanism for calculations."""
from __future__ import absolute_import

from collections import namedtuple

Expand Down
1 change: 0 additions & 1 deletion aiida_cp2k/workchains/base.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
"""Base workchain to run a CP2K calculation"""
from __future__ import absolute_import

from aiida.common import AttributeDict
from aiida.engine import while_
Expand Down
1 change: 0 additions & 1 deletion conftest.py
@@ -1,7 +1,6 @@
"""
For pytest initialise a test database and profile
"""
from __future__ import absolute_import
import pytest
pytest_plugins = ['aiida.manage.tests.pytest_fixtures'] # pylint: disable=invalid-name

Expand Down
3 changes: 0 additions & 3 deletions examples/single_calculations/example_dft.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run simple DFT calculation."""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
Expand Down
3 changes: 0 additions & 3 deletions examples/single_calculations/example_dft_atomic_kinds.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run DFT calculation with different atomic kinds."""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/single_calculations/example_failure.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Run failing calculation."""
from __future__ import print_function
from __future__ import absolute_import

import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/single_calculations/example_geopt.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Run DFT geometry optimization."""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions examples/single_calculations/example_mm.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Run molecular mechanics calculation."""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
Expand Down
3 changes: 0 additions & 3 deletions examples/single_calculations/example_multiple_force_eval.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run DFT calculation with multiple force eval sections."""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
Expand Down
3 changes: 0 additions & 3 deletions examples/single_calculations/example_no_struct.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run DFT calculation with structure specified in the input file."""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
Expand Down
2 changes: 0 additions & 2 deletions examples/single_calculations/example_precision.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Test structure roundtrip precision ase->aiida->cp2k->aiida->ase."""
from __future__ import print_function
from __future__ import absolute_import

import os
import sys
Expand Down
2 changes: 0 additions & 2 deletions examples/single_calculations/example_restart.py
Expand Up @@ -7,8 +7,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Test CP2K restart."""
from __future__ import print_function
from __future__ import absolute_import

import os
import re
Expand Down
Expand Up @@ -8,13 +8,9 @@
###############################################################################
"""Run simple DFT calculation"""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
from six.moves import range

import ase.io

Expand Down
3 changes: 0 additions & 3 deletions examples/single_calculations/fixme_bands.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run simple Band Structure calculation"""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import click
Expand Down
3 changes: 0 additions & 3 deletions examples/workchains/example_base.py
Expand Up @@ -8,9 +8,6 @@
###############################################################################
"""Run simple DFT calculation through a workchain."""

from __future__ import print_function
from __future__ import absolute_import

import os
import sys
import ase.io
Expand Down
46 changes: 21 additions & 25 deletions setup.json
Expand Up @@ -7,15 +7,12 @@
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
"Programming Language :: Python :: 3"
],
"description": "The official AiiDA plugin for CP2K.",
"install_requires": [
"aiida-core>=1.0.0,<1.1.0",
"ase==3.17.0; python_version<'3.0'",
"ase; python_version>='3.5'",
"aiida-core>=1.1.0,<2.0.0",
"ase",
"ruamel.yaml>=0.16.5"
],
"entry_points": {
Expand All @@ -31,25 +28,24 @@
]
},
"extras_require": {
"test": [
"pgtest==1.2.0",
"pytest>=4.4,<5.0.0",
"pytest-cov>=2.6.1,<3.0.0",
"coverage"
],
"pre-commit":[
"pre-commit==1.18.3",
"yapf==0.28.0",
"prospector==1.1.7",
"pylint==1.9.4; python_version<'3.0'",
"pylint==2.3.1; python_version>='3.0'"
],
"docs": [
"sphinx",
"sphinx-rtd-theme",
"sphinxcontrib-contentui",
"sphinxcontrib-details-directive; python_version>='3.0'"
]
"test": [
"pgtest==1.2.0",
"pytest>=4.4,<5.0.0",
"pytest-cov>=2.6.1,<3.0.0",
"coverage"
],
"pre-commit":[
"pre-commit==1.18.3",
"yapf==0.28.0",
"prospector==1.1.7",
"pylint==2.3.1"
],
"docs": [
"sphinx",
"sphinx-rtd-theme",
"sphinxcontrib-contentui",
"sphinxcontrib-details-directive"
]
},
"license": "MIT License",
"name": "aiida_cp2k",
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -6,7 +6,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Setting up CP2K plugin for AiiDA"""
from __future__ import absolute_import

import json

Expand Down
2 changes: 0 additions & 2 deletions test/test_input_generator.py
Expand Up @@ -7,8 +7,6 @@
###############################################################################
"""Test Cp2k input generator"""

from __future__ import absolute_import

import pytest

from aiida_cp2k.utils import Cp2kInput
Expand Down
2 changes: 0 additions & 2 deletions test/test_version_agreement.py
Expand Up @@ -6,8 +6,6 @@
# For further information on the license, see the LICENSE.txt file. #
###############################################################################
"""Check versions"""
from __future__ import print_function
from __future__ import absolute_import

import sys
import json
Expand Down

0 comments on commit ed80b8c

Please sign in to comment.