summaryrefslogtreecommitdiff
path: root/doc/development_guide/contribute.rst
blob: 0f758bda8f84a4ec19f27d7bfbb692a61eb9461a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
.. -*- coding: utf-8 -*-

==============
 Contributing
==============

Bug reports, feedback
---------------------

You think you have found a bug in Pylint? Well, this may be the case
since Pylint is under heavy development.

Please take the time to check if it is already in the issue tracker at
https://github.com/PyCQA/pylint

If you cannot find it in the tracker, create a new issue there or discuss your
problem on the code-quality@python.org mailing list.

The code-quality mailing list is also a nice place to provide feedback about
Pylint, since it is shared with other tools that aim at improving the quality of
python code.

Note that if you don't find something you have expected in Pylint's
issue tracker, it may be because it is an issue with one of its dependencies, namely
astroid:

* https://github.com/PyCQA/astroid

Mailing lists
-------------

You can subscribe to this mailing list at
http://mail.python.org/mailman/listinfo/code-quality

Archives are available at
http://mail.python.org/pipermail/code-quality/

Archives before April 2013 are available at
http://lists.logilab.org/pipermail/python-projects/


.. _repository:

Repository
----------

Pylint is developed using the git_ distributed version control system.

You can clone Pylint and its dependencies from ::

  git clone https://github.com/PyCQA/pylint
  git clone https://github.com/PyCQA/astroid

.. _git: https://git-scm.com/

Got a change for Pylint?  Below are a few steps you should take to make sure
your patch gets accepted.

- Test your code

    - Pylint is very well tested, with a high good code coverage.
      It has two types of tests, usual unittests and functional tests.

      The usual unittests can be found under `/test` directory and they can
      be used for testing almost anything Pylint related. But for the ease
      of testing Pylint's messages, we also have the concept of functional tests.             

    - You should also run all the tests to ensure that your change isn't
      breaking one. You can run the tests using the tox_ package, as in::

          python -m tox
          python -m tox -epy27 # for Python 2.7 suite only
          python -m tox -epylint # for running Pylint over Pylint's codebase

    - To run only a specific test suite, use a pattern for the test filename
      (**without** the ``.py`` extension), as in::

        python -m tox -e py27 -- -k test_functional
        python -m tox -e py27 -- -k  \*func\*

- Add a short entry to the ChangeLog describing the change, except for internal
  implementation only changes. Not usually required, but for changes other than small
  bugs we also add a couple of sentences in the release document for that release,
  (`What's New` section)

- Add yourself to the `CONTRIBUTORS` file, if you are not already there.

- Write a comprehensive commit message

- Relate your change to an issue in the tracker if such an issue exists (see
  `Closing issues via commit messages`_ of the GitHub documentation for more
   information on this)

- Document your change, if it is a non-trivial one.

- Send a pull request from GitHub (see `About pull requests`_ for more insight
  about this topic)


.. _functional_tests:

Functional Tests
----------------

These are residing under '/test/functional' and they are formed of multiple
components. First, each Python file is considered to be a test case and it
should be accompanied by a .txt file, having the same name, with the messages
that are supposed to be emitted by the given test file.

In the Python file, each line for which Pylint is supposed to emit a message
has to be annotated with a comment in the form ``# [message_symbol]``, as in::

    a, b, c = 1 # [unbalanced-tuple-unpacking]

If multiple messages are expected on the same line, then this syntax can be used::

    a, b, c = 1.test # [unbalanced-tuple-unpacking, no-member]

The syntax of the .txt file has to be this::

    symbol:line_number:function_or_class:Expected message

For example, this is a valid message line::

    abstract-class-instantiated:79:main:Abstract class 'BadClass' with abstract methods instantiated

If the Python file is expected to not emit any errors, then the .txt file has to be empty.
If you need special control over Pylint's flag, you can also create a .rc file, which
can have sections of Pylint's configuration.

During development, it's sometimes helpful to run all functional tests in your
current environment in order to have faster feedback. Run with::

    python pylint/test/test_functional.py

.. _`Closing issues via commit messages`: https://help.github.com/articles/closing-issues-via-commit-messages/
.. _`About pull requests`: https://help.github.com/articles/using-pull-requests/
.. _tox: http://tox.readthedocs.io/en/latest/


Tips for Getting Started with Pylint Development
------------------------------------------------
* Read the :ref:`technical-reference`. It gives a short walkthrough of the pylint
  codebase and will help you identify where you will need to make changes
  for what you are trying to implement.
* :func:`astroid.extract_node` is your friend. Most checkers are AST based,
  so you will likely need to interact with :mod:`astroid`.
  A short example of how to use :func:`astroid.extract_node` is given
  :ref:`here <astroid_extract_node>`.
* When fixing a bug for a specific check, search the code for the warning
  message to find where the warning is raised,
  and therefore where the logic for that code exists.

A Typical Development Workflow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#. Create a virtualenv in which to work::

     $ tox

#. Write the tests. See :ref:`functional_tests`.
#. Check that the tests fail::

     $ tox

#. Fix pylint!
#. Make sure your tests pass::

     $ tox

   It is also possible to give tox a `pytest specifier <https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests>`_
   to run only your test::

     $ tox pylint/test/test_functional.py::test_functional

#. Package up and submit your changes as outlined in `repository`_.