Skip to content

Commit

Permalink
Merge pull request #108 from stfc/Update_pylint_file
Browse files Browse the repository at this point in the history
Update pylintrc file
  • Loading branch information
DavidFair authored Nov 21, 2023
2 parents 7708756 + a050917 commit 83da014
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 20 deletions.
40 changes: 20 additions & 20 deletions OpenStack-Rabbit-Consumer/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no

# Clear in-memory caches upon conclusion of linting. Useful if running pylint
# in a server-like mode.
clear-cache-post-run=no

# Load and enable all available extensions. Use --list-extensions to see a list
# all available extensions.
#enable-all-extensions=
Expand Down Expand Up @@ -63,7 +67,7 @@ ignored-modules=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"
#init-hook=

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use, and will cap the count on Windows to
Expand Down Expand Up @@ -248,22 +252,15 @@ check-protected-access-in-special-methods=no
defining-attr-methods=__init__,
__new__,
setUp,
asyncSetUp,
__post_init__

# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,
_fields,
_replace,
_source,
_make
exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit

# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls

# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=cls

valid-metaclass-classmethod-first-arg=mcs

[DESIGN]

Expand Down Expand Up @@ -309,9 +306,7 @@ min-public-methods=2
[EXCEPTIONS]

# Exceptions that will emit a warning when caught.
overgeneral-exceptions=builtins.BaseException,
builtins.Exception

overgeneral-exceptions=builtins.BaseException,builtins.Exception

[FORMAT]

Expand Down Expand Up @@ -410,10 +405,15 @@ confidence=HIGH,
# --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=line-too-long,
missing-module-docstring,
missing-function-docstring,
fixme
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead,
line-too-long

# 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 Expand Up @@ -500,8 +500,8 @@ min-similarity-lines=4
# Limits count of emitted suggestions for spelling mistakes.
max-spelling-suggestions=4

# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the 'python-enchant' package.
# Spelling dictionary name. No available dictionaries : You need to install
# both the python package and the system dependency for enchant to work..
spelling-dict=

# List of comma separated words that should be considered directives if they
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/aq_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file defines methods to be used to interact with the
Aquilon API
"""
import logging
import subprocess
from typing import Optional, List
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/aq_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file defines the class to handle deserialised metadata for
Aquilon
"""
import logging
from dataclasses import dataclass
from typing import Dict, Optional
Expand Down
5 changes: 5 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/consumer_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
This file allows us to set environment variables so that
credentials are not exposed
"""

import os
from dataclasses import dataclass, field
from functools import partial
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/message_consumer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file manages how rabbit messages stating AQ VM creation and deletion
should be handled and processed between the consumer and Aquilon
"""
import json
import logging
import socket
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file deserializes a server's network address from an
OpenStack API response
"""
import logging
import socket
from dataclasses import dataclass, field
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/openstack_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file defines methods for connecting and interacting with the
OpenStack API
"""
import logging
from typing import List, Optional

Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/rabbit_message.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This file handles how messages from Rabbit are processed and the
message extracted
"""
from dataclasses import dataclass, field
from typing import Optional

Expand Down
3 changes: 3 additions & 0 deletions OpenStack-Rabbit-Consumer/rabbit_consumer/vm_data.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
This file has a dataclass for creating VM data objects from messages
"""
from dataclasses import dataclass

from rabbit_consumer.rabbit_message import RabbitMessage
Expand Down
3 changes: 3 additions & 0 deletions OpenStack-Rabbit-Consumer/test/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Fixtures for unit tests, used to create mock objects
"""
import uuid

import pytest
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_aq_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Tests that we perform the correct REST requests against
the Aquilon API
"""
from unittest import mock
from unittest.mock import patch, call, NonCallableMock

Expand Down
5 changes: 5 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_aq_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
Tests the AQ metadata dataclass, including
init from environment variables, and overriding values
"""

from typing import Dict

import pytest
Expand Down
4 changes: 4 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_consumer_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Test the consumer config class, this handles the environment variables
that are used to configure the consumer.
"""
import pytest

from rabbit_consumer.consumer_config import ConsumerConfig
Expand Down
7 changes: 7 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_message_consumer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Tests the message consumption flow
for the consumer
"""
from unittest.mock import Mock, NonCallableMock, patch, call, MagicMock

import pytest
Expand Down Expand Up @@ -413,6 +417,9 @@ def test_delete_machine_by_serial(aq_api, vm_data, openstack_address):
@patch("rabbit_consumer.message_consumer.aq_api")
@patch("rabbit_consumer.message_consumer.socket")
def test_delete_machine_no_hostname(socket_api, aq_api, vm_data):
"""
Tests
"""
aq_api.check_host_exists.return_value = False

ip_address = "127.0.0.1"
Expand Down
3 changes: 3 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_openstack_address.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Tests the dataclass representing OpenStack network addresses
"""
import copy
from unittest.mock import patch

Expand Down
9 changes: 9 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_openstack_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Tests that the Openstack API functions are invoked
as expected with the correct params
"""
from unittest.mock import NonCallableMock, patch

# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -29,9 +33,14 @@ def test_openstack_connection(mock_connect, mock_config):
project_domain_name="default",
)

# Pylint is unable to see that openstack.connect returns a mock
# pylint: disable=no-member
assert conn == mock_connect.return_value
# pylint: disable=no-member
assert conn.close.call_count == 0

# Check close is called when the context manager exits
# pylint: disable=no-member
assert conn.close.call_count == 1


Expand Down
3 changes: 3 additions & 0 deletions OpenStack-Rabbit-Consumer/test/test_rabbit_message.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""
Tests rabbit messages are consumed correctly from the queue
"""
import json
from typing import Dict

Expand Down

0 comments on commit 83da014

Please sign in to comment.