Skip to content

Commit

Permalink
IMPROVEMENT: More pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amilcarlucas committed Apr 15, 2024
1 parent 01572c5 commit 5f14f87
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 41 deletions.
2 changes: 0 additions & 2 deletions MethodicConfigurator/annotate_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
Supports sorting the parameters
Has unit tests with 88% coverage
AP_FLAKE8_CLEAN
Author: Amilcar do Carmo Lucas, IAV GmbH
"""

Expand Down
2 changes: 0 additions & 2 deletions MethodicConfigurator/extract_param_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
Currently has 95% unit test coverage
AP_FLAKE8_CLEAN
Amilcar do Carmo Lucas, IAV GmbH
'''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

def download_license(package_name, license_url):
try:
response = requests.get(license_url)
response = requests.get(license_url, timeout=10)
response.raise_for_status() # Raise an exception if the request failed
# Use a fixed filename for the Mozilla Public License version 2.0
if package_name in ["Scrollable_TK_frame", "Python_Tkinter_ComboBox"]:
Expand Down
34 changes: 23 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
from setuptools import setup
from setuptools import find_packages
#!/usr/bin/env python3

'''
This script downloads the licenses of the direct and indirect dependencies of the project
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator
(C) 2024 Amilcar do Carmo Lucas, IAV GmbH
SPDX-License-Identifier: GPL-3
'''

import os

from setuptools import setup
from setuptools import find_packages

from MethodicConfigurator.version import VERSION


Expand Down Expand Up @@ -35,20 +47,20 @@ def package_files(directory):
# Add any other development requirements here
]

prj_url = "https://github.com/ArduPilot/MethodicConfigurator"
PRJ_URL = "https://github.com/ArduPilot/MethodicConfigurator"

# Read the long description from the README file
with open('README.md', 'r', encoding='utf-8') as f:
long_description = f.read()
# Use Absolute links so that the pyPI page renders correctly
long_description = long_description.replace("(USERMANUAL.md", f"({prj_url}/blob/master/USERMANUAL.md")
long_description = long_description.replace("(CONTRIBUTING.md", f"({prj_url}/blob/master/CONTRIBUTING.md")
long_description = long_description.replace("(ARCHITECTURE.md", f"({prj_url}/blob/master/ARCHITECTURE.md")
long_description = long_description.replace("(CODE_OF_CONDUCT.md", f"({prj_url}/blob/master/CODE_OF_CONDUCT.md")
long_description = long_description.replace("(LICENSE.md", f"({prj_url}/blob/master/LICENSE.md")
long_description = long_description.replace("(credits/CREDITS.md", f"({prj_url}/blob/master/credits/CREDITS.md")
long_description = long_description.replace("(USERMANUAL.md", f"({PRJ_URL}/blob/master/USERMANUAL.md")
long_description = long_description.replace("(CONTRIBUTING.md", f"({PRJ_URL}/blob/master/CONTRIBUTING.md")
long_description = long_description.replace("(ARCHITECTURE.md", f"({PRJ_URL}/blob/master/ARCHITECTURE.md")
long_description = long_description.replace("(CODE_OF_CONDUCT.md", f"({PRJ_URL}/blob/master/CODE_OF_CONDUCT.md")
long_description = long_description.replace("(LICENSE.md", f"({PRJ_URL}/blob/master/LICENSE.md")
long_description = long_description.replace("(credits/CREDITS.md", f"({PRJ_URL}/blob/master/credits/CREDITS.md")
long_description = long_description.replace("images/App_screenshot1.png",
f"{prj_url}/raw/master/images/App_screenshot1.png")
f"{PRJ_URL}/raw/master/images/App_screenshot1.png")

setup(
name='MethodicConfigurator',
Expand All @@ -57,7 +69,7 @@ def package_files(directory):
description='A clear configuration sequence for ArduPilot vehicles',
long_description=long_description,
long_description_content_type='text/markdown',
url=prj_url,
url=PRJ_URL,
author='Amilcar do Carmo Lucas',
author_email='[email protected]',
packages=find_packages(),
Expand Down
4 changes: 2 additions & 2 deletions unittests/annotate_params_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
parameter documentation (if not cached) and adds it to the specified file or
to all *.param and *.parm files in the specified directory.
AP_FLAKE8_CLEAN
Author: Amilcar do Carmo Lucas, IAV GmbH
'''

# pylint: skip-file

import tempfile
from unittest.mock import patch, mock_open
import os
Expand Down
23 changes: 2 additions & 21 deletions unittests/ardupilot_methodic_configurator_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
SPDX-License-Identifier: GPL-3
'''

# pylint: skip-file

import argparse
import unittest
from unittest.mock import patch, MagicMock, mock_open

Check failure on line 15 in unittests/ardupilot_methodic_configurator_unittest.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (F401)

unittests/ardupilot_methodic_configurator_unittest.py:15:34: F401 `unittest.mock.MagicMock` imported but unused

Check failure on line 15 in unittests/ardupilot_methodic_configurator_unittest.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (F401)

unittests/ardupilot_methodic_configurator_unittest.py:15:45: F401 `unittest.mock.mock_open` imported but unused
from ardupilot_methodic_configurator import argument_parser
from ardupilot_methodic_configurator import create_connection_with_retry
from ardupilot_methodic_configurator import read_params_from_files


class TestArgumentParser(unittest.TestCase):
Expand All @@ -25,24 +25,5 @@ def test_argument_parser(self, mock_args):
self.assertEqual(args.params, 'params_dir')


class TestConnectionCreation(unittest.TestCase):
@patch('param_gui.mavutil.mavlink_connection', return_value=MagicMock())
def test_create_connection_with_retry(self, mock_mavlink_connection):
conn_string = 'tcp:127.0.0.1:5760'
master = create_connection_with_retry(conn_string)
self.assertEqual(master, "")
mock_mavlink_connection.assert_called_once_with(conn_string, timeout=5)


class TestReadParamsFromFiles(unittest.TestCase):
@patch('os.listdir', return_value=['file1.param'])
@patch('builtins.open', new_callable=mock_open, read_data='param1 1.0\nparam2 2.0')
def test_read_params_from_files(self, mock_file, mock_listdir):
params_dir = '.'
params = read_params_from_files(params_dir)
expected_params = {'file1.param': {'param1': '1.0', 'param2': '2.0'}}
self.assertEqual(params, expected_params)


if __name__ == '__main__':
unittest.main()
2 changes: 2 additions & 0 deletions unittests/backend_filesystem_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
SPDX-License-Identifier: GPL-3
'''

# pylint: skip-file

import unittest
# import os
from unittest.mock import patch, MagicMock
Expand Down
4 changes: 2 additions & 2 deletions unittests/extract_param_defaults_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
'''
Extracts parameter default values from an ArduPilot .bin file. Unittests.
AP_FLAKE8_CLEAN
Amilcar do Carmo Lucas, IAV GmbH
'''

# pylint: skip-file

import unittest
from unittest.mock import patch, MagicMock

Expand Down
2 changes: 2 additions & 0 deletions unittests/frontend_tkinter_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
SPDX-License-Identifier: GPL-3
'''

# pylint: skip-file

import unittest
from unittest.mock import patch, MagicMock
import tkinter as tk
Expand Down
2 changes: 2 additions & 0 deletions unittests/param_pid_adjustment_update_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
SPDX-License-Identifier: GPL-3
'''

# pylint: skip-file

import unittest
import argparse
import os
Expand Down

0 comments on commit 5f14f87

Please sign in to comment.