Hi,
I'm new to PyLint. I'm writing a python script to calculate the Coding
Convention Error by changing the formula in .pylintrc file:
10.0 - ((float(5 * error + warning + refactor + convention) / statement) *
10)
When I run the script I get the following response.
Using config file /private/var/root/.pylintrc
************* Module shortQuestion
W: 5, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 6, 0: Found indentation with tabs instead of spaces (mixed-…
[View More]indentation)
W: 7, 0: Found indentation with tabs instead of spaces (mixed-indentation)
W: 8, 0: Found indentation with tabs instead of spaces (mixed-indentation)
C: 1, 0: Module name "shortQuestion" doesn't conform to snake_case naming
style (invalid-name)
C: 1, 0: Missing module docstring (missing-docstring)
C: 4, 0: Function name "isContained" doesn't conform to snake_case naming
style (invalid-name)
C: 4, 0: Missing function docstring (missing-docstring)
R: 5, 1: Unnecessary "else" after "return" (no-else-return)
W: 4,16: Unused argument 'cls' (unused-argument)
----------------------------------------------------------------------
Your code has been rated at -15.00/10 (previous run: 10.00/10, -25.00)
Is the -15.00/10 the required error? If yes, how can I get the formatted
response? Secondly I'm redirecting output of
pylint.lint.Run() using StringIO() but still get the following on the
console.
Using config file ~/.pylintrc
Using config file ~/.pylintrc
Using config file ~/.pylintrc
How can I avoid this?
Following is the code snippet for calculating cyclomatic complexity:
my_output = StringIO()
reporter = TextReporter(output=my_output)
pylint_opts = ['file.py','--load-plugins=pylint.extensions.mccabe',
'--max-complexity=0','--rcfile=~/.pylintrc','--msg-template=
{msg_id},{symbol},{msg}']
pylint.lint.Run(pylint_opts,reporter=reporter, exit=False)
output_str = my_output.getvalue()
Thanks
[View Less]
Hi,
I'd like to explore the idea of adopting the 'doc8' tool within the
PyCQA organization. For anyone not familiar with the tool, 'doc8'
markets itself as "an opinionated style checker for rst (with basic
support for plain text) styles of documentation." It's currently
maintained within the OpenStack community but there have been some
valid concerns raised recently regarding the health of the 'doc8' tool
[1]. While it is extensively used within OpenStack (and outside it too,
fwiw), it's very …
[View More]much secondary to the core goal of OpenStack itself,
which probably explains the lack of attention it's received over the
last few years.
While 'doc8' is not a checker for Python code itself, it is Python-
based, is a "quality tool", and rST+docutils/Sphinx remains the
documentation tool of choice for the Python community. For this reason,
I think PyCQA might be a good fit as a parent organization. The other
possible parent organizations I've been looking at are sphinx-
doc/sphinx-contrib and docutils, but doc8 isn't actually Sphinx-based,
which kind of rules out the former, while the docutils community are
_still_ insisting on Sourceforge and Subversion, ruling them out :(
Does anyone else think PyCQA might possibly make a good fit for 'doc8'?
If so, I'll raise the idea formally within OpenStack and start on the
paperwork to move things across. If not, I'd welcome other ideas for
where this useful project could live.
Stephen
[1] http://lists.openstack.org/pipermail/openstack-discuss/2019-July/007669.html
[View Less]
Hi,
I'm trying to configure the no-docstring-rgx option to ignore function and
class names that:
- Starts with _
- Starts with test_
- Ends with tests
- Ends with Tests
I came up with the following regular expression:
(^(test)?_)|((T|t)ests$)
When I test the regular expression on https://regex101.com/r/3BXmsa/6, it
matches the text I expect it to match.
However, when I run pylint against my code, it still reports a docstring is
missing for a class name that ends with Tests.
For example, …
[View More]if I have the following python 3 code.
import unittest
class _Utils(unittest.TestCase):
pass
class Test_Foo(unittest.TestCase):
pass
class test_Foo(unittest.TestCase):
pass
class UtilsTests(unittest.TestCase):
def test_function_name(self):
pass
def _foo(self):
pass
def my_tests(self):
pass
if __name__ == "__main__":
unittest.main()
Running pylint --disable=all --enable=missing-docstring
--no-docstring-rgx='(^(test)?_)|((T|t)ests$)' ./test.py yields
$ pylint --disable=all --enable=missing-docstring
--no-docstring-rgx='(^(test)?_)|((T|t)ests$)' ./test.py
************* Module test
test.py:1:0: C0111: Missing module docstring (missing-docstring)
test.py:8:0: C0111: Missing class docstring (missing-docstring)
test.py:16:0: C0111: Missing class docstring (missing-docstring)
test.py:24:4: C0111: Missing method docstring (missing-docstring)
------------------------------------------------------------------
Your code has been rated at 7.50/10 (previous run: 7.50/10, +0.00)
I was only expecting to see the Missing module docstring violation, and the
missing class docstring on line 8.
Here is my environment:
$ pylint --version
pylint 2.3.1
astroid 2.2.5
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)]
Any ideas what is going on and how to fix it?
Cheers,
Bassam
---
"What we can or cannot do, what we consider possible or impossible, is
rarely a function of our true capability. It is more likely a function of
our beliefs about who we are." - Tony Robbins
[View Less]