Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
Pylint 1.5 upgrade - Fix new warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
antoviaque committed Mar 29, 2016
1 parent 37d3aad commit bb2086a
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 71 deletions.
1 change: 1 addition & 0 deletions instance/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# Imports #####################################################################

from django.contrib import admin

from instance.models.instance import OpenEdXInstance
from instance.models.log_entry import GeneralLogEntry, InstanceLogEntry, ServerLogEntry
from instance.models.server import OpenStackServer
Expand Down
7 changes: 3 additions & 4 deletions instance/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@

# Imports #####################################################################

from contextlib import contextmanager
import logging
import os
import shutil
import subprocess
import yaml

from contextlib import contextmanager
from tempfile import mkdtemp, NamedTemporaryFile
import yaml

from django.conf import settings


# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions instance/gandi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

# Imports #####################################################################

import logging
import time
import xmlrpc.client

Expand All @@ -31,7 +32,6 @@

# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand All @@ -45,14 +45,14 @@ def __init__(self, api_url='https://rpc.gandi.net/xmlrpc/'):
self.client = xmlrpc.client.ServerProxy(api_url)

@property
def api_key(self): #pylint: disable=no-self-use
def api_key(self):
"""
Gandi API key
"""
return settings.GANDI_API_KEY

@property
def zone_id(self): #pylint: disable=no-self-use
def zone_id(self):
"""
Gandi Zone ID of the domain
"""
Expand Down
6 changes: 3 additions & 3 deletions instance/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@

# Imports #####################################################################

import logging
import functools
import operator
import re
import requests
import yaml

from django.conf import settings
from django.template.defaultfilters import truncatewords
import requests
import yaml


# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand Down
5 changes: 2 additions & 3 deletions instance/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@

# Imports #####################################################################

from functools import wraps
import logging
import traceback

from functools import wraps
from swampdragon.pubsub_providers.data_publisher import publish_data

from django.apps import apps
from django.db import models
from swampdragon.pubsub_providers.data_publisher import publish_data

from instance.serializers.logentry import LogEntrySerializer

Expand Down
10 changes: 4 additions & 6 deletions instance/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import logging
import os
import string

from functools import partial

from django.conf import settings
Expand Down Expand Up @@ -365,7 +364,7 @@ class Meta:
abstract = True

@property
def default_fork(self): #pylint: disable=no-self-use
def default_fork(self):
"""
Name of the fork to use by default, when no repository is specified
"""
Expand Down Expand Up @@ -462,7 +461,6 @@ def set_to_branch_tip(self, branch_name=None, ref_type=None, commit=True):
# Update the hash in the instance title if it is present there
# TODO: Find a better way to handle this - include the hash dynamically?
if self.name and old_commit_short_id:
#pylint: disable=attribute-defined-outside-init
self.name = self.name.replace(old_commit_short_id, self.commit_short_id)

if commit:
Expand All @@ -489,7 +487,7 @@ def update_from_pr(self, pr):
"""
Update this instance with settings from the given pull request
"""
self.name = ('PR#{pr.number}: {pr.truncated_title}' + #pylint: disable=attribute-defined-outside-init
self.name = ('PR#{pr.number}: {pr.truncated_title}' +
' ({pr.username}) - {i.reference_name}').format(pr=pr, i=self)
self.github_pr_url = pr.github_pr_url

Expand Down Expand Up @@ -648,7 +646,7 @@ class Meta:
abstract = True

@property
def mysql_database_names(self): #pylint: disable=no-self-use
def mysql_database_names(self):
"""
An iterable of database names
"""
Expand Down Expand Up @@ -691,7 +689,7 @@ class Meta:
abstract = True

@property
def mongo_database_names(self): #pylint: disable=no-self-use
def mongo_database_names(self):
"""
An iterable of database names
"""
Expand Down
6 changes: 2 additions & 4 deletions instance/models/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@
# Imports #####################################################################

import logging
import novaclient
import time

from swampdragon.pubsub_providers.data_publisher import publish_data

import novaclient
from django.conf import settings
from django.db import models
from django.db.models import Q
from django.db.models.signals import post_save
from django_extensions.db.models import TimeStampedModel
from swampdragon.pubsub_providers.data_publisher import publish_data

from instance import openstack
from instance.logger_adapter import ServerLoggerAdapter
from instance.utils import is_port_open, to_json

from instance.models.instance import OpenEdXInstance
from instance.models.utils import ValidateModelMixin

Expand Down
7 changes: 3 additions & 4 deletions instance/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@

# Imports #####################################################################

import requests

from novaclient.client import Client as NovaClient
import logging

from django.conf import settings
from novaclient.client import Client as NovaClient
import requests

from instance.utils import get_requests_retry


# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand Down
6 changes: 3 additions & 3 deletions instance/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

# Imports #####################################################################

import git
import logging
import tempfile
import shutil

from contextlib import contextmanager

import git


# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand Down
4 changes: 2 additions & 2 deletions instance/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

# Imports #####################################################################

from huey.djhuey import crontab, db_periodic_task, db_task
import logging

from huey.contrib.djhuey import crontab, db_periodic_task, db_task
from django.conf import settings

from instance.github import get_username_list_from_team, get_pr_list_from_username
Expand All @@ -32,7 +33,6 @@

# Logging #####################################################################

import logging
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion instance/tests/api/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# Imports #####################################################################

from mock import call, patch

from rest_framework import status

from instance import github
Expand Down
11 changes: 5 additions & 6 deletions instance/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@

# Imports #####################################################################

import huey
import json
import os.path
import re

from mock import Mock

import huey
from django.contrib.auth.models import User
from django.test import Client, TestCase as DjangoTestCase
from mock import Mock


# Functions ###################################################################
Expand Down Expand Up @@ -94,12 +93,12 @@ def setUp(self):

# Don't close tasks DB connections in tests, this conflicts with the atomic transaction blocks
# used by the test runner to isolate DB operations from each test
self.orig_db_connection_close = huey.djhuey.connection.close
self.orig_db_connection_close = huey.contrib.djhuey.connection.close
self.mock_db_connection_close = Mock()
huey.djhuey.connection.close = self.mock_db_connection_close
huey.contrib.djhuey.connection.close = self.mock_db_connection_close

def tearDown(self):
huey.djhuey.connection.close = self.orig_db_connection_close
huey.contrib.djhuey.connection.close = self.orig_db_connection_close


class WithUserTestCase(DjangoTestCase):
Expand Down
2 changes: 1 addition & 1 deletion instance/tests/integration/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Imports #####################################################################

from huey import djhuey
from huey.contrib import djhuey

from instance.models.server import OpenStackServer
from instance.tests.base import TestCase
Expand Down
1 change: 1 addition & 0 deletions instance/tests/integration/factories/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

# Imports #####################################################################

import uuid

import factory
Expand Down
3 changes: 2 additions & 1 deletion instance/tests/models/factories/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

# Imports #####################################################################

from functools import wraps

import factory
from factory.django import DjangoModelFactory
from functools import wraps
from mock import MagicMock, Mock, patch

from instance.models.server import OpenStackServer
Expand Down
3 changes: 1 addition & 2 deletions instance/tests/models/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
import os
import re
import subprocess
from mock import call, patch
from urllib.parse import urlparse

from django.conf import settings
from django.test import override_settings

from mock import call, patch
import pymongo
import yaml

Expand Down
2 changes: 1 addition & 1 deletion instance/tests/models/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import http.client
import io

import novaclient
from mock import Mock, call, patch
import novaclient

from instance.models.server import OpenStackServer, ServerNotReady
from instance.tests.base import AnyStringMatching, TestCase
Expand Down
3 changes: 2 additions & 1 deletion instance/tests/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import os.path
from unittest import mock
from unittest.mock import patch

import yaml

from instance import ansible
Expand Down Expand Up @@ -70,7 +71,7 @@ def test_yaml_merge(self):
Merge of two yaml strings with overlapping variables
"""
yaml_result_str = ansible.yaml_merge(self.yaml_str1, self.yaml_str2)
self.assertEquals(yaml.load(yaml_result_str), {
self.assertEqual(yaml.load(yaml_result_str), {
'testa': 'firsta with unicode «ταБЬℓσ»',
'testb': 'secondb with unicode «ταБЬℓσ2»',
'testc': 'secondc',
Expand Down
4 changes: 2 additions & 2 deletions instance/tests/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

# Imports #####################################################################

import requests

from collections import namedtuple
from unittest.mock import Mock, call, patch

import requests

from instance import openstack
from instance.tests.base import TestCase

Expand Down
2 changes: 1 addition & 1 deletion instance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

import itertools
import json
import requests
import selectors
import socket
import time

from mock import Mock
import requests


# Functions ###################################################################
Expand Down
Loading

0 comments on commit bb2086a

Please sign in to comment.