{"id":13468536,"url":"https://github.com/gforcada/flake8-builtins","last_synced_at":"2025-04-04T11:16:20.812Z","repository":{"id":43612542,"uuid":"52920670","full_name":"gforcada/flake8-builtins","owner":"gforcada","description":"Check for python builtins being used as variables or parameters","archived":false,"fork":false,"pushed_at":"2024-06-01T11:48:52.000Z","size":337,"stargazers_count":114,"open_issues_count":3,"forks_count":24,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T10:09:51.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flake8-builtins","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gforcada.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-02T00:26:51.000Z","updated_at":"2025-02-13T15:32:50.000Z","dependencies_parsed_at":"2023-01-30T17:16:09.854Z","dependency_job_id":"4979f164-2905-4268-813d-defaaa89bfd4","html_url":"https://github.com/gforcada/flake8-builtins","commit_stats":{"total_commits":235,"total_committers":18,"mean_commits":"13.055555555555555","dds":0.3191489361702128,"last_synced_commit":"d5feb508e03fde622a57a1d3a9556ec7d2080450"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gforcada%2Fflake8-builtins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gforcada%2Fflake8-builtins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gforcada%2Fflake8-builtins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gforcada%2Fflake8-builtins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gforcada","download_url":"https://codeload.github.com/gforcada/flake8-builtins/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166169,"owners_count":20894654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:01:13.045Z","updated_at":"2025-04-04T11:16:20.793Z","avatar_url":"https://github.com/gforcada.png","language":"Python","funding_links":[],"categories":["Python","Topics Index","Linters \u0026 Style Checkers","Naming"],"sub_categories":["Code Quality and Linting"],"readme":".. -*- 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 \u003e 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 \u003e 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 \u003cmodule\u003e\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.8, 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgforcada%2Fflake8-builtins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgforcada%2Fflake8-builtins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgforcada%2Fflake8-builtins/lists"}