Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#111] Adds and runs linters #110

Merged
merged 9 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
env/
dist/
venv/
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/make -f
LINT_TARGETS=./src

debian_changelog:
ifndef DAS_CLI_VERSION
Expand All @@ -20,3 +21,15 @@ endif

@bats tests/integration/*.bats --filter-tags '!cluster'

isort:
@isort --settings-path ./src/.isort.cfg $(LINT_TARGETS)

black:
@black --config ./src/.black.cfg $(LINT_TARGETS)

flake8:
@flake8 --config ./src/.flake8.cfg $(LINT_TARGETS)

lint: isort black flake8

pre-commit: lint
4 changes: 4 additions & 0 deletions src/.black.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.black]
line-length = 100
target-version = ['py38']
skip-string-normalization = true
4 changes: 4 additions & 0 deletions src/.flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 100
show-source = true
extend-ignore = E203,E501
9 changes: 9 additions & 0 deletions src/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[isort]
py_version = 38
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
line_length = 100
profile = black
skip=src/config/__init__.py
222 changes: 222 additions & 0 deletions src/.pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
[MASTER]

py-version=3.10


[MESSAGES CONTROL]

disable=all
enable=
abstract-method,
anomalous-backslash-in-string,
anomalous-unicode-escape-in-string,
astroid-error,
attribute-defined-outside-init,
bad-classmethod-argument,
bad-except-order,
bad-exception-context,
bad-format-character,
bad-format-string,
bad-format-string-key,
bad-mcs-classmethod-argument,
bad-mcs-method-argument,
bad-open-mode,
bad-option-value,
bad-reversed-sequence,
bad-staticmethod-argument,
bad-str-strip-call,
bad-string-format-type,
bad-super-call,
bare-except,
blacklisted-name,
broad-except,
c-extension-no-member,
cell-var-from-loop,
chained-comparison,
class-variable-slots-conflict,
comparison-with-itself,
consider-iterating-dictionary,
consider-merging-isinstance,
consider-swap-variables,
consider-using-dict-comprehension,
consider-using-enumerate,
consider-using-get,
consider-using-in,
consider-using-join,
consider-using-set-comprehension,
consider-using-sys-exit,
consider-using-ternary,
continue-in-finally,
dangerous-default-value,
deprecated-method,
deprecated-module,
dict-iter-missing-items,
duplicate-except,
duplicate-key,
duplicate-string-formatting-argument,
empty-docstring,
eval-used,
exec-used,
expression-not-assigned,
fatal,
format-combined-specification,
format-needs-mapping,
global-at-module-level,
global-statement,
global-variable-not-assigned,
import-outside-toplevel,
import-self,
inconsistent-return-statements,
init-is-generator,
invalid-all-object,
invalid-characters-in-docstring,
invalid-envvar-default,
invalid-format-index,
invalid-length-returned,
invalid-name,
invalid-slots-object,
literal-comparison,
logging-format-interpolation,
logging-format-truncated,
logging-not-lazy,
logging-too-few-args,
logging-too-many-args,
logging-unsupported-format,
lost-exception,
method-check-failed,
misplaced-bare-raise,
misplaced-future,
missing-format-argument-key,
missing-format-attribute,
missing-format-string-key,
missing-kwoa,
missing-parentheses-for-call-in-test,
mixed-format-string,
multiple-imports,
no-classmethod-decorator,
no-else-continue,
no-self-argument,
non-iterator-returned,
non-parent-init-called,
nonlocal-and-global,
nonlocal-without-binding,
notimplemented-raised,
parse-error,
pointless-statement,
pointless-string-statement,
possibly-unused-variable,
preferred-module,
protected-access,
raising-format-tuple,
redeclared-assigned-name,
redefined-argument-from-local,
redefined-builtin,
redefined-outer-name,
redundant-unittest-assert,
reimported,
relative-beyond-top-level,
return-arg-in-generator,
return-in-init,
self-assigning-variable,
self-cls-assignment,
shallow-copy-environ,
simplifiable-if-expression,
simplifiable-if-statement,
simplify-boolean-expression,
single-string-used-for-slots,
singleton-comparison,
subprocess-popen-preexec-fn,
subprocess-run-check,
super-init-not-called,
too-few-format-args,
too-many-format-args,
too-many-nested-blocks,
too-many-star-expressions,
trailing-comma-tuple,
truncated-format-string,
try-except-raise,
undefined-all-variable,
undefined-loop-variable,
undefined-variable,
unexpected-line-ending-format,
ungrouped-imports,
unidiomatic-typecheck,
unnecessary-comprehension,
unnecessary-pass,
unneeded-not,
unreachable,
unrecognized-inline-option,
unused-format-string-argument,
unused-format-string-key,
unused-import,
unused-variable,
unused-wildcard-import,
used-before-assignment,
used-prior-global-declaration,
useless-else-on-loop,
useless-object-inheritance,
using-constant-test,
wildcard-import,
wrong-exception-operation,
wrong-import-position,
wrong-spelling-in-comment,
wrong-spelling-in-docstring,


[REPORTS]

# Set the output format. Available formats are text, parseable, colorized and json.
output-format=parseable,colorized

# Tells whether to display a full report or only the messages
reports=no


[SCORE]
score=no


[CLASSES]
valid-classmethod-first-arg=cls
valid-metaclass-classmethod-first-arg=mcs


[EXCEPTIONS]
overgeneral-exceptions=builtins.Exception


[BASIC]
good-names=i,j,k,ex,Run,_,logger,T
variable-rgx=(([a-z][a-z0-9_]{0,})|(_[a-z0-9_]*))$
argument-rgx=(F|([a-z][a-z0-9_]{0,})|(_[a-z0-9_]*))$
attr-rgx=(([a-z][a-z0-9_]{0,})|(_[a-z0-9_]*))$
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
bad-names=toto,tutu,tata


[VARIABLES]

dummy-variables-rgx=(_+[a-zA-Z0-9_]*?$)|dummy

# Tells whether we should check for unused import in __init__ files.
init-import=no

# List of additional names supposed to be defined in builtins. Remember that
# you should avoid defining new builtins when possible.
additional-builtins=

# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,_cb

# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes

# List of names allowed to shadow builtins
allowed-redefined-builtins=


[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME
2 changes: 2 additions & 0 deletions src/commands/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .config_module import ConfigModule

__all__ = ["ConfigModule"]
17 changes: 9 additions & 8 deletions src/commands/config/config_cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from typing import Dict, List

from injector import inject
from typing import List, Dict
from common import Settings, StdoutSeverity

from common import (
Command,
CommandGroup,
ReachableIpAddress,
IntRange,
ReachableIpAddress,
RemoteContextManager,
get_server_username,
Settings,
StdoutSeverity,
get_public_ip,
get_rand_token,
get_server_username,
)


Expand Down Expand Up @@ -75,7 +78,7 @@ class ConfigSet(Command):

mongodb.cluster
Indicates whether a MongoDB cluster is being used (true/false).

mongodb.cluster_secret_key
This key is uploaded to all nodes within the MongoDB cluster. It is used for mutual authentication between nodes, ensuring that only authorized nodes can communicate with each other.

Expand Down Expand Up @@ -354,9 +357,7 @@ class ConfigCli(CommandGroup):
parameters such as port numbers, usernames and other configuration settings required by various DAS components.
"""

short_help = (
"'das-cli config' allows you to manage configuration settings for the DAS CLI"
)
short_help = "'das-cli config' allows you to manage configuration settings for the DAS CLI"

@inject
def __init__(
Expand Down
1 change: 1 addition & 0 deletions src/commands/config/config_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from common import Module

from .config_cli import ConfigCli


Expand Down
2 changes: 2 additions & 0 deletions src/commands/das/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .das_module import DasModule

__all__ = ["DasModule"]
25 changes: 10 additions & 15 deletions src/commands/das/das_cli.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import os
import sys

import click
import distro
import sys
from config import VERSION
from injector import inject
from common import (
Command,
CommandGroup,
CommandOption,
is_executable_bin,
StdoutSeverity,
)

from common import Command, CommandGroup, CommandOption, StdoutSeverity, is_executable_bin
from config import VERSION

from .das_ubuntu_advanced_packaging_tool import (
DasUbuntuAdvancedPackagingTool,
DasNotFoundError,
DasError,
DasNotFoundError,
DasUbuntuAdvancedPackagingTool,
)


class PermissionError(Exception): ...
class PermissionError(Exception): ... # noqa: E701


class DasCliUpdateVersion(Command):
Expand Down Expand Up @@ -130,6 +127,4 @@ def __init__(
)

def version(self):
self.group = click.version_option(VERSION, message="%(prog)s %(version)s")(
self.group
)
self.group = click.version_option(VERSION, message="%(prog)s %(version)s")(self.group)
1 change: 1 addition & 0 deletions src/commands/das/das_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from common import Module

from .das_cli import DasCli


Expand Down
Loading