summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-04-16 12:14:18 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-04-16 12:14:18 +0200
commit704c15c121b0bfcb098ac79a5e7e848f26165c22 (patch)
treebe0ac82782bd4c274d8c477f75fec43f9f2b075a /doc
parent3302ce68f3968fac095164c17e530728e4c47e5f (diff)
downloadpylint-704c15c121b0bfcb098ac79a5e7e848f26165c22.tar.gz
d-t-w
Diffstat (limited to 'doc')
-rw-r--r--doc/FAQ.txt63
-rw-r--r--doc/beginner_pylint_tutorial.txt88
-rw-r--r--doc/quickstart.txt20
3 files changed, 82 insertions, 89 deletions
diff --git a/doc/FAQ.txt b/doc/FAQ.txt
index e61549a..8d42ea6 100644
--- a/doc/FAQ.txt
+++ b/doc/FAQ.txt
@@ -22,7 +22,7 @@ standard, and tries to enforce a coding style.
A major difference between Pylint and Pychecker_ is that Pylint checks for
style issues, while Pychecker explicitly does not. There are a few other
differences, such as the fact that Pylint does not import live modules while
-Pychecker does (see `6.2 Why does Pychecker catch problems with imports that
+Pychecker does (see `6.2 Why does Pychecker catch problems with imports that
Pylint doesn't?`_).
1.3 Who wrote Pylint?
@@ -37,16 +37,16 @@ section of Pylint's README file.
1.4 Who uses Pylint?
--------------------
-In addition to many individuals, the following projects are known to use pylint
+In addition to many individuals, the following projects are known to use pylint
to help develop better
-code:
+code:
* OSAF Chandler (http://www.osafoundation.org/)
* Xen (http://www.xensource.com/)
* CPS (http://www.nuxeo.org)
* ERP5 (http://www.erp5.org/)
* pyxmpp (http://pyxmpp.jabberstudio.org/)
-* mercurial
+* mercurial
* eXe (http://exelearning.org/)
* PrimaGIS (http://www.primagis.org)
* python-cdd (http://projetos.ossystems.com.br/python-cdd/)
@@ -54,9 +54,9 @@ code:
* ASE (http://dcwww.camp.dtu.dk/campos/ASE/intro.html)
* RunJob (http://projects.fnal.gov/runjob/)
* Slugathon (http://slugathon.python-hosting.com/)
-* Topographica (http://topographica.org/Home/index.html) (at least
+* Topographica (http://topographica.org/Home/index.html) (at least
they intend to do so)
-* http://browsershots.org
+* http://browsershots.org
2. Installation
@@ -65,13 +65,13 @@ code:
2.1 How do I install Pylint?
----------------------------
-The easiest way to install Pylint, if you have the setuptools_ package, is to
+The easiest way to install Pylint, if you have the setuptools_ package, is to
invoke ::
easy_install pylint
-Otherwise, you'll have to download the source for Pylint and its dependencies
-from the Logilab site, or through Pylint's repository. See the user manual for
+Otherwise, you'll have to download the source for Pylint and its dependencies
+from the Logilab site, or through Pylint's repository. See the user manual for
detailed installation instructions.
.. _setuptools: http://pypi.python.org/pypi/setuptools
@@ -79,8 +79,8 @@ detailed installation instructions.
2.2 What kind of versioning system does Pylint use?
---------------------------------------------------
-Pylint uses the Mercurial_ distributed version control system. The URL of the
-repository is: http://www.logilab.org/hg/pylint. To get the latest version of
+Pylint uses the Mercurial_ distributed version control system. The URL of the
+repository is: https://bitbucket.org/logilab/pylint. To get the latest version of
Pylint from the repository, simply invoke ::
hg clone http://www.logilab.org/hg/pylint
@@ -104,7 +104,7 @@ packages. It should be compatible with any python version greater than
3.1 Can I give pylint a file as an argument instead of a module?
-----------------------------------------------------------------
-Pylint expects the name of a package or module as its argument. As a
+Pylint expects the name of a package or module as its argument. As a
convenience,
you can give it a file name if it's possible to guess a module name from
the file's path using the python path. Some examples :
@@ -125,13 +125,13 @@ python path.
- "directory" is a python package and "/whatever" is in the python
path
- - "directory" is a python package and your cwd is "/whatever" and so
+ - "directory" is a python package and your cwd is "/whatever" and so
on...
3.2 Where is the persistent data stored to compare between successive runs?
----------------------------------------------------------------------------
-Analysis data are stored as a pickle file in a directory which is
+Analysis data are stored as a pickle file in a directory which is
localized using the following rules:
* value of the PYLINTHOME environment variable if set
@@ -155,7 +155,7 @@ For example::
3.4 I'd rather not run Pylint from the command line. Can I integrate it with my editor?
---------------------------------------------------------------------------------------
-Yes! Pylint can be integrated with many popular editors and IDEs. The following
+Yes! Pylint can be integrated with many popular editors and IDEs. The following
include Pylint by default:
* emacs (of course)
@@ -164,10 +164,10 @@ include Pylint by default:
http://msdl.cs.mcgill.ca/MSDL/people/denis/meetings/pythonDev)
To use pylint from within vim, see
-http://www.gonzo.kiev.ua/projects/pylint.vim
+http://www.gonzo.kiev.ua/projects/pylint.vim
To use pylint from within komodo_, see
-http://mateusz.loskot.net/2006/01/15/running-pylint-from-komodo/
+http://mateusz.loskot.net/2006/01/15/running-pylint-from-komodo/
To use pylint from within gedit_, see
http://live.gnome.org/Gedit/PylintPlugin
@@ -185,7 +185,7 @@ http://www.wingware.com/doc/edit/pylint
4.1 Is it possible to locally disable a particular message?
-----------------------------------------------------------
-
+
Yes, this feature has been added in pylint 0.11. This may be done by
adding "#pylint: disable=W0123,E4567" at the desired block level
or at the end of the desired line of code
@@ -303,13 +303,13 @@ a name which ends with "mixin" (whatever case).
6.1 Pylint gave my code a negative rating out of ten. That can't be right!
--------------------------------------------------------------------------
-Even though the final rating Pylint renders is nominally out of ten, there's no
+Even though the final rating Pylint renders is nominally out of ten, there's no
lower bound on it. By default, the formula to calculate score is ::
10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-However, this option can be changed in the pylint rc file. If having negative
-values really bugs you, you can set the formula to be the minimum of 0 and the
+However, this option can be changed in the pylint rc file. If having negative
+values really bugs you, you can set the formula to be the minimum of 0 and the
above expression.
@@ -325,29 +325,22 @@ traverses an AST representation of the code.
6.3 I think I found a bug in Pylint. What should I do?
-------------------------------------------------------
-First, you might wish to check Pylint's ticketing system (the 'Tickets' tab at
-http://www.logilab.org/project/pylint), to make sure it hasn't been reported
-already. If it hasn't, please send a bug report to python-projects@logilab.org.
-
-Notice that if you don't find something you have expected in pylint's
-tracker page, it may be on the tracker page of one of its dependencies, namely
-astng and common:
-
-* http://www.logilab.org/project/name/logilab-astng
-* http://www.logilab.org/project/name/logilab-common
+First, you might wish to check Pylint's ticketing system (the 'Issues' tab at
+https://bitbucket.org/logilab/pylint), to make sure it hasn't been reported
+already. If it hasn't, please create a new issue there.
6.4 I have a question about Pylint that isn't answered here.
------------------------------------------------------------
-The python-projects@logilab.org mailing list is a great place to discuss and
-ask questions about Pylint. This is a
+The python-projects@logilab.org mailing list is a great place to discuss and
+ask questions about Pylint. This is a
moderated mailing list, so if you're not subscribed email you send will have to
be validated first before actually being sent on the list.
You can subscribe to this mailing list at
http://lists.logilab.org/mailman/listinfo/python-projects
-Archives are available at
+Archives are available at
http://lists.logilab.org/pipermail/python-projects/
If you prefer speaking french instead of english, you can use the
@@ -357,6 +350,6 @@ generic forum-fr@logilab.org mailing list:
* archives: http://lists.logilab.org/pipermail/forum-fr
Notice though that this list has a very low traffic since most pylint related
-discussions are done on the python-projects mailing list.
+discussions are done on the python-projects mailing list.
.. _pychecker: http://pychecker.sf.net
diff --git a/doc/beginner_pylint_tutorial.txt b/doc/beginner_pylint_tutorial.txt
index ed0e0ac..327709f 100644
--- a/doc/beginner_pylint_tutorial.txt
+++ b/doc/beginner_pylint_tutorial.txt
@@ -10,26 +10,26 @@ For a detailed description of Pylint, see http://www.logilab.org/project/pylint.
Intro
-----
-Beginner to coding standards? Pylint can be your guide to reveal what's really
+Beginner to coding standards? Pylint can be your guide to reveal what's really
going on behind the scenes and help you to become a more aware programmer.
-Sharing code is a rewarding endeavor. Putting your code 'out there' can be
-either an act of philanthropy, 'coming of age', or a basic extension of belief
-in open source. Whatever the motivation, your good intentions may not have the
+Sharing code is a rewarding endeavor. Putting your code 'out there' can be
+either an act of philanthropy, 'coming of age', or a basic extension of belief
+in open source. Whatever the motivation, your good intentions may not have the
desired outcome if people find your code hard to use or understand. The Python
-community has formalized some recommended programming styles to help everyone
-write code in a common, agreed-upon style that makes the most sense for shared
-code. This style is captured in PEP-8_. Pylint can be a quick and easy way of
-seeing if your code has captured the essence of PEP-8 and is therefore
+community has formalized some recommended programming styles to help everyone
+write code in a common, agreed-upon style that makes the most sense for shared
+code. This style is captured in PEP-8_. Pylint can be a quick and easy way of
+seeing if your code has captured the essence of PEP-8 and is therefore
'friendly' to other potential users.
Perhaps you're not ready to share your code but you'd like to learn a bit more
-about writing better code and don't know where to start. Pylint can tell you
+about writing better code and don't know where to start. Pylint can tell you
where you may have run astray and point you in the direction to figure out what
you have done and how to do better.
-This tutorial is all about approaching coding standards with little or no
-knowledge of in-depth programming or the code standards themselves. It's the
+This tutorial is all about approaching coding standards with little or no
+knowledge of in-depth programming or the code standards themselves. It's the
equivalent of skipping the manual and jumping right in.
My command line prompt for these examples is: ::
@@ -83,22 +83,22 @@ Pylint is going to 'pick on': ::
When Pylint is first run on a fresh piece of code, a common complaint is that it
is too 'noisy'. The current default configuration is set to enforce all possible
-warnings. We'll use some of the options I noted above to make it suit your
+warnings. We'll use some of the options I noted above to make it suit your
preferences a bit better (and thus make it 'scream only when needed').
Your First Pylint'ing
---------------------
-We'll use a basic python script as fodder for our tutorial. I borrowed
+We'll use a basic python script as fodder for our tutorial. I borrowed
extensively from the code here: http://www.daniweb.com/code/snippet748.html
-The starting code we will use is called simplecaeser.py and is here in its
+The starting code we will use is called simplecaeser.py and is here in its
entirety: ::
1 #!/usr/bin/env python
- 2
+ 2
3 import string
- 4
+ 4
5 shift = 3
6 choice = raw_input("would you like to encode or decode?")
7 word = (raw_input("Please enter text"))
@@ -118,7 +118,7 @@ entirety: ::
21 else:
22 x = letters.index(letter) - shift
23 encoded = encoded + letters[x]
- 24
+ 24
25 print encoded
@@ -126,7 +126,7 @@ Let's get started.
If we run this: ::
- robertk01 Desktop$ pylint simplecaeser.py
+ robertk01 Desktop$ pylint simplecaeser.py
No config file found, using default configuration
************* Module simplecaeser
C: 1: Missing docstring
@@ -234,18 +234,18 @@ If we run this: ::
Wow. That's a lot of stuff. The first part is the 'messages' section while the
second part is the 'report' section. There are two points I want to tackle here.
-First point is that all the tables of statistics (i.e. the report) are a bit
+First point is that all the tables of statistics (i.e. the report) are a bit
overwhelming so I want to silence them. To do that, I will use the "--reports=n" option.
-Second, previous experience taught me that the default output for the messages
+Second, previous experience taught me that the default output for the messages
needed a bit more info. We can see the first line is: ::
"C: 1: Missing docstring"
-This basically means that line 1 violates a convention 'C'. It's telling me I
+This basically means that line 1 violates a convention 'C'. It's telling me I
really should have a docstring. I agree, but what if I didn't fully understand
what rule I violated. Knowing only that I violated a convention isn't much help
-if I'm a newbie. So let's turn on a bit more info by using the option
+if I'm a newbie. So let's turn on a bit more info by using the option
"--include-ids=y".
.. tip:: Many of Pylint's commonly used command line options have shortcuts.
@@ -254,7 +254,7 @@ if I'm a newbie. So let's turn on a bit more info by using the option
Let's do it again! ::
- robertk01 Desktop$ pylint --reports=n --include-ids=y simplecaeser.py
+ robertk01 Desktop$ pylint --reports=n --include-ids=y simplecaeser.py
No config file found, using default configuration
************* Module simplecaeser
C0111: 1: Missing docstring
@@ -267,20 +267,20 @@ Let's do it again! ::
C0322: 16: Operator not preceded by a space
encoded=encoded + letters[x]
-Oooh. I like that better. Now I know that I violated the convention number
-C0111 and now I can read up a bit more about that. Let's go back to the
+Oooh. I like that better. Now I know that I violated the convention number
+C0111 and now I can read up a bit more about that. Let's go back to the
command line and try this: ::
robertk01 Desktop$ pylint --help-msg=C0111
No config file found, using default configuration
:C0111: *Missing docstring*
Used when a module, function, class or method has no docstring. Some special
- methods like __init__ doesn't necessary require a docstring. This message
+ methods like __init__ doesn't necessary require a docstring. This message
belongs to the basic checker.
Yeah, ok. That one was a bit of a no-brainer but I have run into error messages
that left me with no clue about what went wrong, simply because I was unfamiliar
-with the underlying mechanism of code theory. One error that puzzled my newbie
+with the underlying mechanism of code theory. One error that puzzled my newbie
mind was: ::
:R0902: *Too many instance attributes (%s/%s)*
@@ -292,16 +292,16 @@ pour a fresh cup of coffee and look into it - let your programmer mind grow!
The Next Step
-------------
-Now that we got some configuration stuff out of the way, let's see what we can
+Now that we got some configuration stuff out of the way, let's see what we can
do with the remaining warnings.
-If we add a docstring to describe what the code is meant to do that will help.
+If we add a docstring to describe what the code is meant to do that will help.
I'm also going to be a bit cowboy and ignore the W0402 message because I like to
take risks in life. A deprecation warning means that future versions of Python
may not support that code so my code may break in the future. There are 5 C0103
messages that we will get to later. Lastly, I violated the convention of using
spaces around an operator such as "=" so I'll fix that too. To sum up, I'll add
-a docstring to line 2, put spaces around the = sign on line 16 and use the
+a docstring to line 2, put spaces around the = sign on line 16 and use the
"--disable=W0402" to ignore the deprecation warning.
Here's the updated code: ::
@@ -309,9 +309,9 @@ Here's the updated code: ::
1 #!/usr/bin/env python
2 """This script prompts a user to enter a message to encode or decode
3 using a classic Caeser shift substitution (3 letter shift)"""
- 4
+ 4
5 import string
- 6
+ 6
7 shift = 3
8 choice = raw_input("would you like to encode or decode?")
9 word = (raw_input("Please enter text"))
@@ -331,12 +331,12 @@ Here's the updated code: ::
23 else:
24 x = letters.index(letter) - shift
25 encoded = encoded + letters[x]
- 26
+ 26
27 print encoded
And here's what happens when we run it with our --disable=W0402 option: ::
- robertk01 Desktop$ pylint --reports=n --include-ids=y --disable=W0402 simplecaeser.py
+ robertk01 Desktop$ pylint --reports=n --include-ids=y --disable=W0402 simplecaeser.py
No config file found, using default configuration
************* Module simplecaeser
C0103: 7: Invalid name "shift" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
@@ -347,35 +347,35 @@ And here's what happens when we run it with our --disable=W0402 option: ::
Nice! We're down to just the C0103 messages.
-There are fairly well defined conventions around naming things like instance
-variables, functions, classes, etc. The conventions focus on the use of
-UPPERCASE and lowercase as well as the characters that separate multiple words
-in the name. This lends itself well to checking via a regular expression, thus
+There are fairly well defined conventions around naming things like instance
+variables, functions, classes, etc. The conventions focus on the use of
+UPPERCASE and lowercase as well as the characters that separate multiple words
+in the name. This lends itself well to checking via a regular expression, thus
the "should match (([A-Z\_][A-Z1-9\_]*)|(__.*__))$".
-In this case Pylint is telling me that those variables appear to be constants
+In this case Pylint is telling me that those variables appear to be constants
and should be all UPPERCASE. This rule is in fact a naming convention that is
specific to the folks at Logilab who created Pylint. That is the way they have
chosen to name those variables. You too can create your own in-house naming
conventions but for the purpose of this tutorial, we want to stick to the PEP-8
standard. In this case, the variables I declared should follow the convention
of all lowercase. The appropriate rule would be something like:
-"should match [a-z\_][a-z0-9\_]{2,30}$". Notice the lowercase letters in the
+"should match [a-z\_][a-z0-9\_]{2,30}$". Notice the lowercase letters in the
regular expression (a-z versus A-Z).
-If we run that rule using a --const-rgx='[a-z\_][a-z0-9\_]{2,30}$' option, it
+If we run that rule using a --const-rgx='[a-z\_][a-z0-9\_]{2,30}$' option, it
will now be quite quiet: ::
- robertk01 Desktop$ pylint --reports=n --include-ids=y --disable=W0402 --const-rgx='[a-z_][a-z0-9_]{2,30}$' simplecaeser.py
+ robertk01 Desktop$ pylint --reports=n --include-ids=y --disable=W0402 --const-rgx='[a-z_][a-z0-9_]{2,30}$' simplecaeser.py
No config file found, using default configuration
-Regular expressions can be quite a beast so take my word on this particular
+Regular expressions can be quite a beast so take my word on this particular
example but go ahead and `read up`_ on them if you want.
.. tip::
It would really be a pain in the butt to have to use all these options
on the command line all the time. That's what the rc file is for. We can
- configure our Pylint to store our options for us so we don't have to declare
+ configure our Pylint to store our options for us so we don't have to declare
them on the command line. Using the rc file is a nice way of formalizing your
rules and quickly sharing them with others. Invoking 'pylint
--generate-rcfile' will create a sample rcfile with all the options set and
diff --git a/doc/quickstart.txt b/doc/quickstart.txt
index 27f80b4..a772e8c 100644
--- a/doc/quickstart.txt
+++ b/doc/quickstart.txt
@@ -51,11 +51,11 @@ your ``PYTHONPATH``, since it is a common error to analyze an
installed version of a module instead of the development version.
It is also possible to analyze python files, with a few
-restrictions. The thing to keep in mind is that Pylint will try to
+restrictions. The thing to keep in mind is that pylint will try to
convert the file name to a module name, and only be able to process
the file if it succeeds. ::
- pylint mymodule.py
+ pylint mymodule.py
should always works since the current working
directory is automatically added on top of the python path ::
@@ -87,7 +87,7 @@ There are several sections in Pylint's output.
Source code analysis section
''''''''''''''''''''''''''''
-
+
For each python module,
Pylint will first display a few '*' characters followed by the name
of the module. Then, a number of messages with the following
@@ -111,7 +111,7 @@ Sometimes the line of code which caused the error is displayed with
a caret pointing to the error. This may be generalized in future
versions of Pylint.
-Example (extracted from a run of pylint on itself...):
+Example (extracted from a run of pylint on itself...):
::
@@ -128,23 +128,23 @@ Example (extracted from a run of pylint on itself...):
Reports section
-'''''''''''''''
+'''''''''''''''
Following the analysis message, Pylint will display a set of reports,
each one focusing on a particular aspect of the project, such as number
of messages by categories, modules dependencies...
For instance, the metrics report displays summaries gathered from the
-current run.
+current run.
* the number of processed modules
* for each module, the percentage of errors and warnings
* the total number of errors and warnings
* percentage of classes, functions and modules with docstrings, and
- a comparison from the previous run
+ a comparison from the previous run
* percentage of classes, functions and modules with correct name
(according to the coding standard), and a comparison from the
- previous run
+ previous run
* a list of external dependencies found in the code, and where they appear
Also, a global evaluation for the code is computed, and an
@@ -155,7 +155,7 @@ specified on the command line).
Command line options
--------------------
-First of all, we have two basic (but useful) options.
+First of all, we have two basic (but useful) options.
--version show program's version number and exit
-h, --help show help about the command line options
@@ -164,7 +164,7 @@ Pylint is architectured around several checkers. By default all
checkers are enabled. You can disable a specific checker or some of its
messages or messages categories by specifying
``--disable=<id>``. If you want to enable only some checkers or some
-message ids, first use ``--disable=all`` then
+message ids, first use ``--disable=all`` then
``--enable=<id>`` with <id> being a comma separated list of checker
names and message identifiers. See the list of available features_ for a
description of provided checkers with their functionalities.