Name | flake8-builtins JSON |
Version |
3.0.0
JSON |
| download |
home_page | None |
Summary | Check for python builtins being used as variables or parameters |
upload_time | 2025-08-17 06:33:50 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
flake8
pep8
python
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. -*- coding: utf-8 -*-
.. image:: https://github.com/gforcada/flake8-builtins/actions/workflows/testing.yml/badge.svg?branch=main
:target: https://github.com/gforcada/flake8-builtins/actions/workflows/testing.yml
.. image:: https://coveralls.io/repos/gforcada/flake8-builtins/badge.svg?branch=main
:target: https://coveralls.io/github/gforcada/flake8-builtins?branch=main
Flake8 Builtins plugin
======================
Check for python builtins being used as variables or parameters.
Imagine some code like this:
.. code:: Python
def max_values(list, list2):
max = list[0]
for x in list:
if x > 0:
max = x
all_values = list()
all_values.append(max)
max = list2[0]
for x in list2:
if x > 0:
max = x
all_values.append(max)
return all_values
max_values([3, 4, 5, ], [5, 6, 7])
The last statement is not returning ``[5, 7]`` as one would expect,
instead is raising this exception::
Traceback (most recent call last):
File "test.py", line 17, in <module>
max_values([3,4,5], [4,5,6])
File "bla.py", line 6, in max_values
all_values = list()
TypeError: 'list' object is not callable
**Why?** Because ``max_value`` function's first argument is ``list`` a Python builtin.
Python allows to override them, but although could be useful in some really specific use cases,
the general approach is to **not** do that as code then can suddenly break without a clear trace.
Example
-------
Given the following code:
.. code:: Python
def my_method(object, list, dict):
max = 5
min = 3
zip = (4, 3)
The following warnings are shown (via flake8)::
test.py:1:15: A002 argument "object" is shadowing a python builtin
test.py:1:23: A002 argument "list" is shadowing a python builtin
test.py:1:29: A002 argument "dict" is shadowing a python builtin
test.py:2:5: A001 variable "max" is shadowing a python builtin
test.py:3:5: A001 variable "min" is shadowing a python builtin
test.py:4:5: A001 variable "zip" is shadowing a python builtin
Install
-------
Install with pip::
$ python -m pip install flake8-builtins
Options
-------
One can use `--builtins-ignorelist` option, or configuration option,
to ignore a custom list of builtins::
$ flake8 --builtins-ignorelist id,copyright *.py
Requirements
------------
- Python 3.9, 3.10, 3.11, 3.12, and pypy3
- flake8
Rules
-----
A001:
A variable is shadowing a Python builtin.
A002:
An argument is shadowing a Python builtin.
A003:
A class attribute is shadowing a Python builtin.
A004:
An import statement is shadowing a Python builtin.
A005:
A module is shadowing a Python builtin module (e.g: `logging` or `socket`)
A006:
A lambda argument is shadowing a Python builtin.
License
-------
GPL 2.0
Raw data
{
"_id": null,
"home_page": null,
"name": "flake8-builtins",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "flake8, pep8, python",
"author": null,
"author_email": "Gil Forcada Codinachs <gil.gnome@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/88/96/abb083bdde679597d0ccee3cf7117ca092607a7efe657fbf0363dcf47eee/flake8_builtins-3.0.0.tar.gz",
"platform": null,
"description": ".. -*- coding: utf-8 -*-\n\n.. image:: https://github.com/gforcada/flake8-builtins/actions/workflows/testing.yml/badge.svg?branch=main\n :target: https://github.com/gforcada/flake8-builtins/actions/workflows/testing.yml\n\n.. image:: https://coveralls.io/repos/gforcada/flake8-builtins/badge.svg?branch=main\n :target: https://coveralls.io/github/gforcada/flake8-builtins?branch=main\n\nFlake8 Builtins plugin\n======================\nCheck for python builtins being used as variables or parameters.\n\nImagine some code like this:\n\n.. code:: Python\n\n def max_values(list, list2):\n max = list[0]\n for x in list:\n if x > 0:\n max = x\n\n all_values = list()\n all_values.append(max)\n\n max = list2[0]\n for x in list2:\n if x > 0:\n max = x\n all_values.append(max)\n\n return all_values\n\n max_values([3, 4, 5, ], [5, 6, 7])\n\nThe last statement is not returning ``[5, 7]`` as one would expect,\ninstead is raising this exception::\n\n Traceback (most recent call last):\n File \"test.py\", line 17, in <module>\n max_values([3,4,5], [4,5,6])\n File \"bla.py\", line 6, in max_values\n all_values = list()\n TypeError: 'list' object is not callable\n\n**Why?** Because ``max_value`` function's first argument is ``list`` a Python builtin.\nPython allows to override them, but although could be useful in some really specific use cases,\nthe general approach is to **not** do that as code then can suddenly break without a clear trace.\n\nExample\n-------\nGiven the following code:\n\n.. code:: Python\n\n def my_method(object, list, dict):\n max = 5\n min = 3\n zip = (4, 3)\n\nThe following warnings are shown (via flake8)::\n\n test.py:1:15: A002 argument \"object\" is shadowing a python builtin\n test.py:1:23: A002 argument \"list\" is shadowing a python builtin\n test.py:1:29: A002 argument \"dict\" is shadowing a python builtin\n test.py:2:5: A001 variable \"max\" is shadowing a python builtin\n test.py:3:5: A001 variable \"min\" is shadowing a python builtin\n test.py:4:5: A001 variable \"zip\" is shadowing a python builtin\n\nInstall\n-------\nInstall with pip::\n\n $ python -m pip install flake8-builtins\n\nOptions\n-------\n\nOne can use `--builtins-ignorelist` option, or configuration option,\nto ignore a custom list of builtins::\n\n $ flake8 --builtins-ignorelist id,copyright *.py\n\nRequirements\n------------\n- Python 3.9, 3.10, 3.11, 3.12, and pypy3\n- flake8\n\nRules\n-----\n\nA001:\n A variable is shadowing a Python builtin.\n\nA002:\n An argument is shadowing a Python builtin.\n\nA003:\n A class attribute is shadowing a Python builtin.\n\nA004:\n An import statement is shadowing a Python builtin.\n\nA005:\n A module is shadowing a Python builtin module (e.g: `logging` or `socket`)\n\nA006:\n A lambda argument is shadowing a Python builtin.\n\nLicense\n-------\nGPL 2.0\n",
"bugtrack_url": null,
"license": null,
"summary": "Check for python builtins being used as variables or parameters",
"version": "3.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/gforcada/flake8-builtins/issues",
"Changelog": "https://github.com/gforcada/flake8-builtins/blob/main/CHANGES.rst",
"Homepage": "https://github.com/gforcada/flake8-builtins"
},
"split_keywords": [
"flake8",
" pep8",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6557ec9248238058a894a07768026dcad6e9c2f868b3503d79e697b7754fb1f7",
"md5": "5faedfac0dba469a1278740c560e0f93",
"sha256": "d5d3c545ff3a71c8f1b2f7589a06d6740b26e38e6ce1f3954a25f32ec5829b42"
},
"downloads": -1,
"filename": "flake8_builtins-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5faedfac0dba469a1278740c560e0f93",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 11955,
"upload_time": "2025-08-17T06:33:48",
"upload_time_iso_8601": "2025-08-17T06:33:48.785476Z",
"url": "https://files.pythonhosted.org/packages/65/57/ec9248238058a894a07768026dcad6e9c2f868b3503d79e697b7754fb1f7/flake8_builtins-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8896abb083bdde679597d0ccee3cf7117ca092607a7efe657fbf0363dcf47eee",
"md5": "810ed53e6a8c1788bf717cf322a93411",
"sha256": "bab4d458de6b828634f789f84cb31aff2ab5f92cd37b4f3888ffa5e78cd9d373"
},
"downloads": -1,
"filename": "flake8_builtins-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "810ed53e6a8c1788bf717cf322a93411",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 16661,
"upload_time": "2025-08-17T06:33:50",
"upload_time_iso_8601": "2025-08-17T06:33:50.249564Z",
"url": "https://files.pythonhosted.org/packages/88/96/abb083bdde679597d0ccee3cf7117ca092607a7efe657fbf0363dcf47eee/flake8_builtins-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-17 06:33:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gforcada",
"github_project": "flake8-builtins",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "flake8-builtins"
}