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

Linter enabled tests #1985

Merged
merged 8 commits into from
Aug 21, 2020
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
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ matrix:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=2.7.pylintrc"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/ga azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py setup.py makepkg.py tests"
- python: 3.4
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=2.7.pylintrc"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/ga azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py setup.py makepkg.py tests"
- python: 3.6
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/ga azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py setup.py makepkg.py tests"
- python: 3.7
env:
- >-
NOSEOPTS="--verbose --with-timer" SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/ga azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py setup.py makepkg.py tests"
- python: 3.8
env:
- >-
Expand All @@ -50,7 +50,7 @@ matrix:
--cover-package=azurelinuxagent --cover-xml"
SETUPOPTS=""
PYLINTOPTS="--rcfile=3.6.pylintrc"
PYLINTFILES="azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py azurelinuxagent/ga setup.py makepkg.py"
PYLINTFILES="azurelinuxagent/ga azurelinuxagent/common/ azurelinuxagent/daemon azurelinuxagent/agent.py setup.py makepkg.py tests"

install:
- pip install -r requirements.txt
Expand Down
14 changes: 12 additions & 2 deletions 2.7.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,39 @@
# anomalous-backslash-in-string<W1401>: (hi-pri) Used when a backslash is in a literal string but not as an escape.
# arguments-differ<W0221>: (hi-pri) Used when a method has a different number of arguments than in the implemented interface or in an overridden method.
# attribute-defined-outside-init<W0201>: (hi-pri) Used when an instance attribute is defined outside the __init__ method.
# bad-continuation<C0330>: (needs review) **REMOVED in pylint-2.6.0**
# bad-indentation<W0311>: (hi-pri) Used when an unexpected number of indentation's tabulations or spaces has been found.
# bad-open-mode<W1501>: (hi-pri) Python supports: r, w, a[, x] modes with b, +, and U (only with r) options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a comment for line 9 above

bad-continuation: (needs review) REMOVED in pylint-2.6.0

maybe we should disable this one globally (to the entire project)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can definitely do that.

Note that python2.6 and python3.4 are stuck on earlier versions that do have this symbol (any of 3.[6,7,8] might also get stuck on current stable, 2.5.3, which also has this symbol), so I'm not sure if that changes things. We could potentially leave this enabled in this file, and disable it for other versions once they update.

# bad-super-call<E1003>: (hi-pri) Used when another argument than the current class is given as first argument of the super builtin.
# bare-except<W0702>: (hi-pri) Used when an except clause doesn't specify exceptions type to catch.
# blacklisted-name<C0102>: (needs review) Used when the name is listed in the black list (unauthorized names).
# cell-var-from-loop<W0640>: (hi-pri) A variable used in a closure is defined in a loop. This will result in all closures using the same value for the closed-over variable.
# cyclic-import<R0401>: (hi-pri) Used when a cyclic import between two or more modules is detected.
# dangerous-default-value<W0102>: (hi-pri) Used when a mutable value as list or dictionary is detected in a default value for an argument.
# deprecated-method<W1505>: (hi-pri) The method is marked as deprecated and will be removed in a future version of Python.
# duplicate-key<W0109>: (hi-pri) Used when a dictionary expression binds the same key multiple times.
# expression-not-assigned<W0106>: (hi-pri) Used when an expression that is not a function call is assigned to nothing.
# duplicate-code<R0801>: (hi-pri) Indicates that a set of similar lines has been detected among multiple file. (also disabled globally)
# fixme<W0511>: Used when a warning note as FIXME or TODO is detected
# function-redefined<E0102>: (hi-pri) Used when a function / class / method is redefined.
# global-statement<W0603>: Used when you use the "global" statement to update a global variable.
# import-error<E0401>: (hi-pri) Used when pylint has been unable to import a module.
# inconsistent-return-statements<R1710>: (hi-pri) if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function
# invalid-name<C0103>: (needs review) Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
# keyword-arg-before-vararg<W1113>: (hi-pri) When defining a keyword argument before variable positional arguments, one can end up in having multiple values passed for the aforementioned parameter in case the method is called with keyword arguments.
# len-as-condition<C1801>: (hi-pri) Used when Pylint detects that len(sequence) is being used without explicit comparison inside a condition to determine if a sequence is empty.
# logging-format-interpolation<W1202>: (hi-pri) Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead.
# multiple-imports<C0410>: (hi-pri) Used when import statement importing multiple modules is detected.
# no-else-return<R1705>: (hi-pri) Used in order to highlight an unnecessary block of code following an if containing a return statement.
# no-member<E1101>: (hi-pri) Used when a variable is accessed for an unexistent member.
# no-name-in-module<E0611>: (hi-pri) Used when a name cannot be found in a module.
# no-value-for-parameter<E1120>: (hi-pri) Used when a function call passes too few arguments.
# pointless-statement<W0104>: (hi-pri) Used when a statement doesn’t have (or at least seems to) any effect.
# pointless-string-statement<W0105>: (hi-pri) Used when a string is used as a statement (which of course has no effect). This is a particular case of W0104 with its own message so you can easily disable it if you're using those strings as documentation, instead of comments.
# protected-access<W0212>: Used when a protected member (i.e. class member with a name beginning with an underscore) is access outside the class or a descendant of the class where it's defined.
# raising-format-tuple<W0715>: (hi-pri) Used when passing multiple arguments to an exception constructor, the first of them a string literal containing what appears to be placeholders intended for formatting
# redefined-builtin<W0622>: (hi-pri) Used when a variable or function override a built-in.
# redefined-outer-name<W0621>: (hi-pri) Used when a variable's name hides a name defined in the outer scope.
# redundant-unittest-assert<W1503>: (hi-pri) The first argument of assertTrue and assertFalse is a condition. If a constant is passed as parameter, that condition will be always true.
# reimported<W0404>: (hi-pri) Used when a module is reimported multiple times.
# simplifiable-if-statement<R1703>: Used when an if statement can be replaced with 'bool(test)'.
# singleton-comparison<C0121>: (hi-pri) Used when an expression is compared to singleton values like True, False or None.
Expand Down Expand Up @@ -79,7 +88,8 @@

[MESSAGES CONTROL]

disable=bad-option-value, # pylint does not recognize the error code/symbol (needed to supress breaking changes across pylint versions)
disable=bad-continuation, # Buggy, **REMOVED in pylint-2.6.0**
bad-option-value, # pylint does not recognize the error code/symbol (needed to supress breaking changes across pylint versions)
bad-whitespace, # Used when a wrong number of spaces is used around an operator, bracket or block opener.
broad-except, # Used when an except catches a too general exception, possibly burying unrelated errors.
consider-iterating-dictionary, # Emitted when the keys of a dictionary are iterated through the .keys() method.
Expand Down
14 changes: 12 additions & 2 deletions 3.6.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# assignment-from-no-return<E1111>: (hi-pri) Used when an assignment is done on a function call but the inferred function doesn't return anything.
# assignment-from-none<E1128>: (hi-pri) Used when an assignment is done on a function call but the inferred function returns nothing but None.
# attribute-defined-outside-init<W0201>: (hi-pri) Used when an instance attribute is defined outside the __init__ method.
# bad-continuation<C0330>: (needs review) **REMOVED in pylint-2.6.0**
# bad-indentation<W0311>: (hi-pri) Used when an unexpected number of indentation's tabulations or spaces has been found.
# bad-open-mode<W1501>: (hi-pri) Python supports: r, w, a[, x] modes with b, +, and U (only with r) options.
# bad-super-call<E1003>: (hi-pri) Used when another argument than the current class is given as first argument of the super builtin.
# bare-except<W0702>: (hi-pri) Used when an except clause doesn't specify exceptions type to catch.
# cell-var-from-loop<W0640>: (hi-pri) A variable used in a closure is defined in a loop. This will result in all closures using the same value for the closed-over variable.
Expand All @@ -19,16 +19,21 @@
# cyclic-import<R0401>: (hi-pri) Used when a cyclic import between two or more modules is detected.
# dangerous-default-value<W0102>: (hi-pri) Used when a mutable value as list or dictionary is detected in a default value for an argument.
# deprecated-method<W1505>: (hi-pri) The method is marked as deprecated and will be removed in a future version of Python
# duplicate-key<W0109>: (hi-pri) Used when a dictionary expression binds the same key multiple times.
# duplicate-code<R0801>: (hi-pri) Indicates that a set of similar lines has been detected among multiple file. (also disabled globally)
# duplicate-string-formatting-argument<W1308>: (hi-pri) Used when we detect that a string formatting is repeating an argument instead of using named string arguments
# expression-not-assigned<W0106>: (hi-pri) Used when an expression that is not a function call is assigned to nothing.
# fixme<W0511>: Used when a warning note as FIXME or TODO is detected
# function-redefined<E0102>: (hi-pri) Used when a function / class / method is redefined.
# global-statement<W0603>: Used when you use the "global" statement to update a global variable.
# implicit-str-concat<W1404>: (hi-pri) String literals are implicitly concatenated in a literal iterable definition : maybe a comma is missing ?
# import-error<E0401>: (hi-pri) Used when pylint has been unable to import a module.
# inconsistent-return-statements<R1710>: (hi-pri) if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function
# invalid-name<C0103>: (needs review) Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
# keyword-arg-before-vararg<W1113>: (hi-pri) When defining a keyword argument before variable positional arguments, one can end up in having multiple values passed for the aforementioned parameter in case the method is called with keyword arguments.
# len-as-condition<C1801>: (hi-pri) Used when Pylint detects that len(sequence) is being used without explicit comparison inside a condition to determine if a sequence is empty.
# logging-format-interpolation<W1202>: (hi-pri) Used when a logging statement has a call form of "logging.<logging method>(format_string.format(format_args...))". Use another type of string formatting instead.
# multiple-imports<C0410>: (hi-pri) Used when import statement importing multiple modules is detected.
# lost-exception<W0150>: (needs review) Used when a break or a return statement is found inside the finally clause of a try...finally block: the exceptions raised in the try clause will be silently swallowed instead of being re-raised.
# no-else-break<R1723>: (hi-pri) Used in order to highlight an unnecessary block of code following an if containing a break statement.
# no-else-continue<R1724>: (hi-pri) Used in order to highlight an unnecessary block of code following an if containing a continue statement.
Expand All @@ -41,6 +46,7 @@
# raising-format-tuple<W0715>: (hi-pri) Used when passing multiple arguments to an exception constructor, the first of them a string literal containing what appears to be placeholders intended for formatting
# redefined-builtin<W0622>: (hi-pri) Used when a variable or function override a built-in.
# redefined-outer-name<W0621>: (hi-pri) Used when a variable's name hides a name defined in the outer scope.
# redundant-unittest-assert<W1503>: (hi-pri) The first argument of assertTrue and assertFalse is a condition. If a constant is passed as parameter, that condition will be always true.
# reimported<W0404>: (hi-pri) Used when a module is reimported multiple times.
# signature-differs<W0222>: (hi-pri) Used when a method signature is different than in the implemented interface or in an overridden method.
# simplifiable-if-expression<R1719>: Used when an if expression can be replaced with 'bool(test)'.
Expand All @@ -49,6 +55,7 @@
# subprocess-popen-preexec-fn<W1509>: (hi-pri) The preexec_fn parameter is not safe to use in the presence of threads in your application. The child process could deadlock before exec is called.
# super-init-not-called<W0231>: (hi-pri) Used when an ancestor class method has an __init__ method which is not called by a derived class.
# too-few-public-methods<R0903>: Used when class has too few public methods, so be sure it's really worth it.
# too-many-ancestors<R0901>: (hi-pri) Used when class has too many parent classes, try to reduce this to get a simpler (and so easier to use) class.
# too-many-arguments<R0913>: Used when a function or method takes too many arguments.
# too-many-branches<R0912>: Used when a function or method has too many branches, making it hard to follow.
# too-many-instance-attributes<R0902>: Used when class has too many instance attributes, try to reduce this to get a simpler (and so easier to use) class.
Expand All @@ -60,13 +67,15 @@
# undefined-variable<E0602>: (hi-pri) Used when an undefined variable is accessed.
# ungrouped-imports<C0412>: (needs review) Used when imports are not grouped by packages
# unidiomatic-typecheck<C0123>: (hi-pri) The idiomatic way to perform an explicit typecheck in Python is to use isinstance(x, Y) rather than type(x) == Y, type(x) is Y.
# unnecessary-comprehension<R1721>: (hi-pri) Instead of using an identity comprehension, consider using the list, dict or set constructor.
# unnecessary-lambda<W0108>: Used when the body of a lambda expression is a function call on the same argument list as the lambda itself
# unnecessary-pass<W0107>: (hi-pri) Used when a "pass" statement that can be avoided is encountered.
# unnecessary-semicolon<W0301>: Used when a statement is ended by a semi-colon (";"), which isn't necessary
# unneeded-not<C0113>: (needs review) Used when a boolean expression contains an unneeded negation.
# unused-argument<W0613>: (hi-pri) Used when a function or method argument is not used.
# unused-import<W0611>: (hi-pri) Used when an imported module or variable is not used.
# unused-variable<W0612>: (hi-pri) Used when a variable is defined but not used.
# used-before-assignment<E0601>: (hi-pri) Used when a local variable is accessed before its assignment.
# useless-else-on-loop<W0120>: (hi-pri) Loops should only have an else clause if they can exit early with a break statement, otherwise the statements under else should be on the same scope as the loop itself.
# useless-import-alias<C0414>: (hi-pri) Used when an import alias is same as original package.e.g using import numpy as numpy instead of import numpy as np
# useless-return<R1711>: (hi-pri) Emitted when a single "return" or "return None" statement is found at the end of function or method definition.
Expand All @@ -76,7 +85,8 @@

[MESSAGES CONTROL]

disable=bad-whitespace, # Used when a wrong number of spaces is used around an operator, bracket or block opener. **REMOVED IN pylint-2.6.0**
disable=bad-continuation, # Buggy, **REMOVED in pylint-2.6.0**
bad-whitespace, # Used when a wrong number of spaces is used around an operator, bracket or block opener. **REMOVED IN pylint-2.6.0**
broad-except, # Used when an except catches a too general exception, possibly burying unrelated errors.
consider-iterating-dictionary, # Emitted when the keys of a dictionary are iterated through the .keys() method.
consider-using-dict-comprehension, # Although there is nothing syntactically wrong with this code, it is hard to read and can be simplified to a dict comprehension.
Expand Down
4 changes: 2 additions & 2 deletions azurelinuxagent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def parse_args(sys_args): # pylint: disable=R0912
conf_file_path = m.group(1)
if not os.path.exists(conf_file_path):
print("Error: Configuration file {0} does not exist".format(
conf_file_path), file=sys.stderr) # pylint: disable=C0330
conf_file_path), file=sys.stderr)
usage()
sys.exit(1)

Expand Down Expand Up @@ -256,7 +256,7 @@ def usage():
"""
s = "\n" # pylint: disable=C0103
s += ("usage: {0} [-verbose] [-force] [-help] " # pylint: disable=C0103
"-configuration-path:<path to configuration file>" # pylint: disable=C0330
"-configuration-path:<path to configuration file>"
"-deprovision[+user]|-register-service|-version|-daemon|-start|"
"-run-exthandlers|-show-configuration]"
"").format(sys.argv[0])
Expand Down
12 changes: 6 additions & 6 deletions azurelinuxagent/common/cgroupapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ def cgroup_path(tail=""):
if not os.path.exists(path):
fileutil.mkdir(path)
osutil.mount(device='cgroup_root',
mount_point=path, # pylint: disable=C0330
option="-t tmpfs", # pylint: disable=C0330
chk_err=False) # pylint: disable=C0330
mount_point=path,
option="-t tmpfs",
chk_err=False)
elif not os.path.isdir(cgroup_path()):
logger.error("Could not mount cgroups: ordinary file at {0}", path)
return
Expand All @@ -241,9 +241,9 @@ def cgroup_path(tail=""):
if not os.path.exists(target_path):
fileutil.mkdir(target_path)
osutil.mount(device=controller,
mount_point=target_path, # pylint: disable=C0330
option="-t cgroup -o {0}".format(controller), # pylint: disable=C0330
chk_err=False) # pylint: disable=C0330
mount_point=target_path,
option="-t cgroup -o {0}".format(controller),
chk_err=False)
if controller == 'cpu,cpuacct':
cpu_mounted = True
except Exception as exception:
Expand Down
Loading