Skip to content

Commit

Permalink
dts: update dependencies and mypy execution
Browse files Browse the repository at this point in the history
Poetry changed the syntax of dev dependencies section in version
1.2.0. Updated the lock file with Poetry 1.5.1 added that to the
documentation.
The scripts section did nothing, so it got removed.
Update Pylama linters:
* pep8 is the same as pycodestyle
* pylint is missing dependencies and thus not executed. It reports a
  number of warnings and may be introduced in a future patch.
* mypy doesn't work properly with Pylama. Pylama executes linting
  file-by-file and mypy works on all files at once.

Mypy has thus been moved outside Pylama and is executed separately.
Added Mypy configuration that makes it easier to specify ignored issues
in more detail.

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
jlinkes authored and ovsrobot committed Jul 25, 2023
1 parent d2cfa0c commit dd46e31
Show file tree
Hide file tree
Showing 7 changed files with 554 additions and 146 deletions.
21 changes: 20 additions & 1 deletion devtools/dts-check-format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2022 University of New Hampshire
# Copyright(c) 2023 PANTHEON.tech s.r.o.

usage() {
echo "Usage: $(basename $0) [options] [directory]"
Expand All @@ -11,9 +12,10 @@ usage() {

format=true
lint=true
typecheck=true

# Comments after args serve as documentation; must be present
while getopts "hfl" arg; do
while getopts "hflt" arg; do
case $arg in
h) # Display this message
echo 'Run formatting and linting programs for DTS.'
Expand All @@ -26,6 +28,9 @@ while getopts "hfl" arg; do
l) # Don't run linter
lint=false
;;
t) # Don't run type checker
typecheck=false
;;
?)
usage
exit 1
Expand Down Expand Up @@ -93,6 +98,20 @@ if $lint; then
fi
fi

if $typecheck; then
if $format || $lint; then
echo
fi
heading "Checking types in $directory/"
if command -v mypy > /dev/null; then
mypy .
errors=$((errors + $?))
else
echo "mypy not found, unable to check types"
errors=$((errors + 1))
fi
fi

echo
heading "Summary for $directory/"
echo "Found $errors errors"
Expand Down
1 change: 1 addition & 0 deletions doc/guides/tools/dts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Setting up DTS environment
Another benefit is the usage of ``pyproject.toml``, which has become the standard config file
for python projects, improving project organization.
To install Poetry, visit their `doc pages <https://python-poetry.org/docs/>`_.
The recommended Poetry version is at least 1.5.1.

#. **Getting a Poetry shell**

Expand Down
2 changes: 1 addition & 1 deletion dts/framework/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from enum import auto, unique
from typing import Any, TypedDict, Union

import warlock # type: ignore
import warlock # type: ignore[import]
import yaml

from framework.settings import SETTINGS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import socket
import traceback

from paramiko import AutoAddPolicy, SSHClient, Transport # type: ignore
from paramiko.ssh_exception import ( # type: ignore
from paramiko import AutoAddPolicy, SSHClient, Transport # type: ignore[import]
from paramiko.ssh_exception import ( # type: ignore[import]
AuthenticationException,
BadHostKeyException,
NoValidConnectionsError,
Expand Down
2 changes: 1 addition & 1 deletion dts/framework/remote_session/remote/interactive_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pathlib import PurePath
from typing import Callable

from paramiko import Channel, SSHClient, channel # type: ignore
from paramiko import Channel, SSHClient, channel # type: ignore[import]

from framework.logger import DTSLOG
from framework.settings import SETTINGS
Expand Down
643 changes: 510 additions & 133 deletions dts/poetry.lock

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions dts/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2022 University of New Hampshire
# Copyright(c) 2023 PANTHEON.tech s.r.o.

[tool.poetry]
name = "dts"
version = "0.1.0"
description = ""
authors = ["Owen Hilyard <ohilyard@iol.unh.edu>", "dts@dpdk.org"]
description = "DPDK Test Suite."
license = "BSD-3-Clause"
authors = [
"Owen Hilyard <ohilyard@iol.unh.edu>",
"Juraj Linkeš <juraj.linkes@pantheon.tech>",
"Jeremy Spewock <jspewock@iol.unh.edu>"
]
maintainers = [
"Lijuan Tu <lijuan.tu@intel.com>",
"Juraj Linkeš <juraj.linkes@pantheon.tech>"
]
documentation = "https://doc.dpdk.org/guides/tools/dts.html"

[tool.poetry.dependencies]
python = "^3.10"
Expand All @@ -15,28 +26,28 @@ types-PyYAML = "^6.0.8"
fabric = "^2.7.1"
scapy = "^2.5.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
mypy = "^0.961"
black = "^22.6.0"
isort = "^5.10.1"
pylama = "^8.4.1"
pyflakes = "2.5.0"
pyflakes = "^2.5.0"
toml = "^0.10.2"

[tool.poetry.scripts]
dts = "main:main"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.pylama]
linters = "pep8,pylint,mccabe,mypy,pycodestyle,pyflakes"
linters = "mccabe,pycodestyle,pyflakes"
format = "pylint"
max_line_length = 88 # https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length

[tool.mypy]
python_version = "3.10"
enable_error_code = ["ignore-without-code"]
show_error_codes = true
warn_unused_ignores = true

[tool.isort]
profile = "black"
Expand Down

0 comments on commit dd46e31

Please sign in to comment.