Skip to content

Commit

Permalink
Fix broken imports of urllib (#3767)
Browse files Browse the repository at this point in the history
`import urllib` does not automatically make the `urllib.request`
and `urllib.error` modules available.
  • Loading branch information
ltalirz authored Feb 21, 2020
1 parent 94f91a9 commit 11cefed
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion aiida/cmdline/commands/cmd_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# pylint: disable=broad-except,too-many-arguments,too-many-locals,too-many-branches
from enum import Enum
import traceback
import urllib
import urllib.request
import click

from aiida.cmdline.commands.cmd_verdi import verdi
Expand Down
9 changes: 6 additions & 3 deletions aiida/cmdline/params/types/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
###########################################################################
"""Click parameter types for paths."""
import os
import urllib
# See https://stackoverflow.com/a/41217363/1069467
import urllib.request
import urllib.error

import click

Expand Down Expand Up @@ -53,10 +55,11 @@ def __repr__(self):
class ImportPath(click.Path):
"""AiiDA extension of Click's Path-type to include URLs
An ImportPath can either be a `click.Path`-type or a URL.
:param timeout_seconds: Timeout time in seconds that a URL response is expected.
:value timeout_seconds: Must be an int in the range [0;60], extrema included.
If an int outside the range [0;60] is given, the value will be set to the respective extremum value.
If any other type than int is given a TypeError will be raised.
If an int outside the range [0;60] is given, the value will be set to the respective extremum value.
If any other type than int is given a TypeError will be raised.
"""

# pylint: disable=protected-access
Expand Down
2 changes: 1 addition & 1 deletion aiida/manage/configuration/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
###########################################################################
"""Module that defines methods required to setup a new AiiDA instance."""
import os
import urllib
import urllib.parse

import click

Expand Down
2 changes: 1 addition & 1 deletion aiida/restapi/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# For further information please visit http://www.aiida.net #
###########################################################################
""" Util methods """
import urllib
import urllib.parse
from datetime import datetime, timedelta

from flask import jsonify
Expand Down
3 changes: 2 additions & 1 deletion aiida/tools/importexport/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
""" Utility functions for import/export of AiiDA entities """
# pylint: disable=inconsistent-return-statements,too-many-branches,too-many-return-statements
# pylint: disable=too-many-nested-blocks,too-many-locals
import urllib
import urllib.request
import urllib.parse
from html.parser import HTMLParser

from aiida.tools.importexport.common.config import (
Expand Down
4 changes: 1 addition & 3 deletions tests/tools/dbimporters/test_icsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
"""
Tests for IcsdDbImporter
"""
import urllib

import urllib.request
import pytest

from aiida.backends.testbase import AiidaTestCase

from aiida.tools.dbimporters.plugins import icsd


Expand Down

0 comments on commit 11cefed

Please sign in to comment.