flake8-string-format


Nameflake8-string-format JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/xZise/flake8-string-format
Summarystring format checker, plugin for flake8
upload_time2020-02-16 15:27:51
maintainer
docs_urlNone
authorFabian Neundorf
requires_python
licenseMIT License
keywords flake8 format
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            String format parameter checker
===============================

.. image:: https://travis-ci.org/xZise/flake8-string-format.svg?branch=0.3.0
   :alt: Build Status
   :target: https://travis-ci.org/xZise/flake8-string-format

.. image:: http://codecov.io/github/xZise/flake8-string-format/coverage.svg?branch=master
   :alt: Coverage Status
   :target: http://codecov.io/github/xZise/flake8-string-format?branch=master

.. image:: https://badge.fury.io/py/flake8-string-format.svg
   :alt: Pypi Entry
   :target: https://pypi.python.org/pypi/flake8-string-format

An extension for `Flake8 <https://pypi.python.org/pypi/flake8>`_ to check the
strings and parameters using ``str.format``. It checks all strings whether they
use numbered parameters with an implicit index which isn't support in
Python 2.6.

In all instances of ``'…'.format(…)`` it will also check whether there are
enough parameters given. If the format call uses variable arguments, it'll just
check whether the right types of arguments are present.


Plugin for Flake8
-----------------

When both Flake8 and ``flake8-string-format`` are installed, the plugin
is available in ``flake8``::

  $ flake8 --version
  3.0.2 (flake8-string-format: 0.2.3, […]

This plugin supports Flake8 2.6 as well as Flake8 3.0. Older or newer versions
may be supported too but they weren't tested.

Via ``--ignore`` it's possible to ignore unindexed parameters::

  $ flake8 some_file.py
  ...
  some_file.py:1:1: P101 format string does contain unindexed parameters

  $ flake8 --ignore P101 some_file.py
  ...


Parameters
----------

This module doesn't add any additional parameters to Flake8.


Error codes
-----------

This plugin is using the following error codes:

+--------------------------------------------------------------------+
| Presence of implicit parameters                                    |
+------+-------------------------------------------------------------+
| P101 | format string does contain unindexed parameters             |
+------+-------------------------------------------------------------+
| P102 | docstring does contain unindexed parameters                 |
+------+-------------------------------------------------------------+
| P103 | other string does contain unindexed parameters              |
+------+-------------------------------------------------------------+
| Missing values in the parameters                                   |
+------+-------------------------------------------------------------+
| P201 | format call uses too large index (INDEX)                    |
+------+-------------------------------------------------------------+
| P202 | format call uses missing keyword (KEYWORD)                  |
+------+-------------------------------------------------------------+
| P203 | format call uses keyword arguments but no named entries     |
+------+-------------------------------------------------------------+
| P204 | format call uses variable arguments but no numbered entries |
+------+-------------------------------------------------------------+
| P205 | format call uses implicit and explicit indexes together     |
+------+-------------------------------------------------------------+
| Unused values in the parameters                                    |
+------+-------------------------------------------------------------+
| P301 | format call provides unused index (INDEX)                   |
+------+-------------------------------------------------------------+
| P302 | format call provides unused keyword (KEYWORD)               |
+------+-------------------------------------------------------------+


Operation
---------

The plugin will go through all ``bytes``, ``str`` and ``unicode`` instances. If
it encounters ``bytes`` instances on Python 3, it'll decode them using ASCII and
if that fails it'll skip that entry.

The strings are basically sorted into three types corresponding to the P1XX
range. Only the format string can cause all errors while any other string can
only cause the corresponding P1XX error.

For this plugin all strings which are the first expression of the module or
after a function or class definition are considered docstrings.

If the ``format`` method is used on a string or ``str.format`` with the string
as the first parameter, it will consider this a format string and will analyze
the parameters of that call. If that call uses variable arguments, it cannot
issue P201 and P202 as missing entries might be hidden in those variable
arguments. P301 and P302 can still be checked for any argument which is defined
statically.


Python 2.6 support
``````````````````

Python 2.6 is only partially supported as it's using Python's capability to
format a string. So if a string contains implicit parameters, it won't be
detected as a parameter on Python 2.6 and thus it won't cause any P1XX errors.
But it might still cause an error P301 when variable arguments aren't used.

So if Python 2.6 compatibility is wished and thus implicit parameters aren't
allowed, this plugin won't cause false positives.


Changes
-------
0.3.0 - 2020-02-16
``````````````````
* Removed support for standalone version.
* Support multiple starargs and at any location.

0.2.3 - 2016-07-27
``````````````````
* Properly register with Flake8 so it will be selected on Flake8 3.x by default
  and it can be selected on Flake8 2.x.

0.2.2 - 2016-05-29
``````````````````
* Do not check simple expressions, except for docstrings, because they cannot be
  accessed anyway.
* Properly assert starred arguments in Python 3.5. Only the last element must be
  a vararg if varargs are present and not the complete list.
* Output correct column offset on Python 3.4.2, as that used the wrong offset
  inside calls.

0.2.1 - 2015-09-20
``````````````````
* Support ``str.format("…", …)`` calls and handle them like ``"…".format(…)``

0.2.0 - 2015-09-12
``````````````````
* Instead of using a regex it's trying to parse it using Python's parser
* This result can also be used now to verify that enough parameters are given
* Limited Python 2.6 support

0.1.0 - 2015-09-10
``````````````````
* Detect unindexed parameters in all strings
* Separate error code for docstrings



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xZise/flake8-string-format",
    "name": "flake8-string-format",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "flake8 format",
    "author": "Fabian Neundorf",
    "author_email": "CommodoreFabianus@gmx.de",
    "download_url": "https://files.pythonhosted.org/packages/68/db/500e114a9ee115b03a21a2581c227fd932a0f50c4ae8fee514ef9a373cf4/flake8-string-format-0.3.0.tar.gz",
    "platform": "",
    "description": "String format parameter checker\n===============================\n\n.. image:: https://travis-ci.org/xZise/flake8-string-format.svg?branch=0.3.0\n   :alt: Build Status\n   :target: https://travis-ci.org/xZise/flake8-string-format\n\n.. image:: http://codecov.io/github/xZise/flake8-string-format/coverage.svg?branch=master\n   :alt: Coverage Status\n   :target: http://codecov.io/github/xZise/flake8-string-format?branch=master\n\n.. image:: https://badge.fury.io/py/flake8-string-format.svg\n   :alt: Pypi Entry\n   :target: https://pypi.python.org/pypi/flake8-string-format\n\nAn extension for `Flake8 <https://pypi.python.org/pypi/flake8>`_ to check the\nstrings and parameters using ``str.format``. It checks all strings whether they\nuse numbered parameters with an implicit index which isn't support in\nPython 2.6.\n\nIn all instances of ``'\u2026'.format(\u2026)`` it will also check whether there are\nenough parameters given. If the format call uses variable arguments, it'll just\ncheck whether the right types of arguments are present.\n\n\nPlugin for Flake8\n-----------------\n\nWhen both Flake8 and ``flake8-string-format`` are installed, the plugin\nis available in ``flake8``::\n\n  $ flake8 --version\n  3.0.2 (flake8-string-format: 0.2.3, [\u2026]\n\nThis plugin supports Flake8 2.6 as well as Flake8 3.0. Older or newer versions\nmay be supported too but they weren't tested.\n\nVia ``--ignore`` it's possible to ignore unindexed parameters::\n\n  $ flake8 some_file.py\n  ...\n  some_file.py:1:1: P101 format string does contain unindexed parameters\n\n  $ flake8 --ignore P101 some_file.py\n  ...\n\n\nParameters\n----------\n\nThis module doesn't add any additional parameters to Flake8.\n\n\nError codes\n-----------\n\nThis plugin is using the following error codes:\n\n+--------------------------------------------------------------------+\n| Presence of implicit parameters                                    |\n+------+-------------------------------------------------------------+\n| P101 | format string does contain unindexed parameters             |\n+------+-------------------------------------------------------------+\n| P102 | docstring does contain unindexed parameters                 |\n+------+-------------------------------------------------------------+\n| P103 | other string does contain unindexed parameters              |\n+------+-------------------------------------------------------------+\n| Missing values in the parameters                                   |\n+------+-------------------------------------------------------------+\n| P201 | format call uses too large index (INDEX)                    |\n+------+-------------------------------------------------------------+\n| P202 | format call uses missing keyword (KEYWORD)                  |\n+------+-------------------------------------------------------------+\n| P203 | format call uses keyword arguments but no named entries     |\n+------+-------------------------------------------------------------+\n| P204 | format call uses variable arguments but no numbered entries |\n+------+-------------------------------------------------------------+\n| P205 | format call uses implicit and explicit indexes together     |\n+------+-------------------------------------------------------------+\n| Unused values in the parameters                                    |\n+------+-------------------------------------------------------------+\n| P301 | format call provides unused index (INDEX)                   |\n+------+-------------------------------------------------------------+\n| P302 | format call provides unused keyword (KEYWORD)               |\n+------+-------------------------------------------------------------+\n\n\nOperation\n---------\n\nThe plugin will go through all ``bytes``, ``str`` and ``unicode`` instances. If\nit encounters ``bytes`` instances on Python 3, it'll decode them using ASCII and\nif that fails it'll skip that entry.\n\nThe strings are basically sorted into three types corresponding to the P1XX\nrange. Only the format string can cause all errors while any other string can\nonly cause the corresponding P1XX error.\n\nFor this plugin all strings which are the first expression of the module or\nafter a function or class definition are considered docstrings.\n\nIf the ``format`` method is used on a string or ``str.format`` with the string\nas the first parameter, it will consider this a format string and will analyze\nthe parameters of that call. If that call uses variable arguments, it cannot\nissue P201 and P202 as missing entries might be hidden in those variable\narguments. P301 and P302 can still be checked for any argument which is defined\nstatically.\n\n\nPython 2.6 support\n``````````````````\n\nPython 2.6 is only partially supported as it's using Python's capability to\nformat a string. So if a string contains implicit parameters, it won't be\ndetected as a parameter on Python 2.6 and thus it won't cause any P1XX errors.\nBut it might still cause an error P301 when variable arguments aren't used.\n\nSo if Python 2.6 compatibility is wished and thus implicit parameters aren't\nallowed, this plugin won't cause false positives.\n\n\nChanges\n-------\n0.3.0 - 2020-02-16\n``````````````````\n* Removed support for standalone version.\n* Support multiple starargs and at any location.\n\n0.2.3 - 2016-07-27\n``````````````````\n* Properly register with Flake8 so it will be selected on Flake8 3.x by default\n  and it can be selected on Flake8 2.x.\n\n0.2.2 - 2016-05-29\n``````````````````\n* Do not check simple expressions, except for docstrings, because they cannot be\n  accessed anyway.\n* Properly assert starred arguments in Python 3.5. Only the last element must be\n  a vararg if varargs are present and not the complete list.\n* Output correct column offset on Python 3.4.2, as that used the wrong offset\n  inside calls.\n\n0.2.1 - 2015-09-20\n``````````````````\n* Support ``str.format(\"\u2026\", \u2026)`` calls and handle them like ``\"\u2026\".format(\u2026)``\n\n0.2.0 - 2015-09-12\n``````````````````\n* Instead of using a regex it's trying to parse it using Python's parser\n* This result can also be used now to verify that enough parameters are given\n* Limited Python 2.6 support\n\n0.1.0 - 2015-09-10\n``````````````````\n* Detect unindexed parameters in all strings\n* Separate error code for docstrings\n\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "string format checker, plugin for flake8",
    "version": "0.3.0",
    "split_keywords": [
        "flake8",
        "format"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "b18b2004b352f3bd750fe9c65af394d3",
                "sha256": "812ff431f10576a74c89be4e85b8e075a705be39bc40c4b4278b5b13e2afa9af"
            },
            "downloads": -1,
            "filename": "flake8_string_format-0.3.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b18b2004b352f3bd750fe9c65af394d3",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7266,
            "upload_time": "2020-02-16T15:27:49",
            "upload_time_iso_8601": "2020-02-16T15:27:49.327646Z",
            "url": "https://files.pythonhosted.org/packages/e8/22/e5f4ccc41dda8db61cf3bb7a93549f9ae8e1dd10547b3d71cc8483a0b437/flake8_string_format-0.3.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "0feaf071c64dd79884a2c0d189c3971d",
                "sha256": "65f3da786a1461ef77fca3780b314edb2853c377f2e35069723348c8917deaa2"
            },
            "downloads": -1,
            "filename": "flake8-string-format-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0feaf071c64dd79884a2c0d189c3971d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6495,
            "upload_time": "2020-02-16T15:27:51",
            "upload_time_iso_8601": "2020-02-16T15:27:51.045089Z",
            "url": "https://files.pythonhosted.org/packages/68/db/500e114a9ee115b03a21a2581c227fd932a0f50c4ae8fee514ef9a373cf4/flake8-string-format-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-02-16 15:27:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "xZise",
    "github_project": "flake8-string-format",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "flake8-string-format"
}
        
Elapsed time: 0.02147s