flake8-builtins | Check for python builtins being used as variables | Machine Learning library
kandi X-RAY | flake8-builtins Summary
kandi X-RAY | flake8-builtins Summary
Check for python builtins being used as variables or parameters
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Run the builtin function .
- Check whether a statement contains a statement .
- Check if function definition is valid .
- Check for assignment .
- Format an error message .
- Check if a statement is inside a loop .
- Check that all generators are in BUILTINS .
- Check if an exception is found .
- Check if imports are in BUILTINS .
- Initialize the tree .
flake8-builtins Key Features
flake8-builtins Examples and Code Snippets
class Foo:
def open(self, bar):
pass
with open('myfile.txt'):
print('did I get here?')
>>> TypeError: open() missing 1 required positional argument: 'bar'
class Foo:
def print
pip install pandas-stubs
error: Cannot assign to a type
$ cat t2.py
db_utils.wat()
my_var.wat()
$ flake8 t2.py
t2.py:1:1: F821 undefined name 'db_utils'
t2.py:2:1: F821 undefined name 'my_var'
$ flake8 t2.py --builtins db_utils
t2.py:2:1: F821 undefined name 'my_var'
repos:
- repo: https://github.com/life4/flakehell
rev: v.0.7.1
hooks:
- id: flakehell
repos:
- repo: local
hooks:
- id: flakehell
name: flakehell
entry: flak
Community Discussions
Trending Discussions on flake8-builtins
QUESTION
If have some code like this:
...ANSWER
Answered 2022-Jan-05 at 17:11You shouldn't have a problem with the code. As long as the function is referenced with self.open()
and not open()
, it should work. Just make sure the class does not already have an open()
function.
QUESTION
I just had to debug a problem in production that boils down to the following behavior.
What I should have typed:
...ANSWER
Answered 2021-Mar-25 at 13:48QUESTION
I'm trying to run flakehell as pre-commit hook.
my .pre-commit-config.yaml:
...ANSWER
Answered 2021-Jan-11 at 20:19your configuration is incorrect, you haven't limited the files that are passed to your hook with either files
or types
so it is defaulting to all files in your repository. presumably you have some binary file which is being passed to flakehell
I also notice that your configuration passes both a path and has pass_filenames: true
(pass_filenames: true
is the default so you shouldn't use that)
you either want to list paths in args (not recommended since you always lint more than what you're changing) or you want to filter the filenames properly
additionally, verbose: true
is not intended for use outside of debugging as it adds warning noise to the output
additionally, you're not managing the installation of flakehell through pre-commit which will add additional burden to your contributors to try and set up whatever development environment locally, most of the point of pre-commit is that it manages installing your tools so your contributors don't have to jump through hoops to have the correct formatting / linting setup (eliminating a whole class of "it works on my machine" problems)
additionally, it looks like flakehell has direct support for pre-commit, so you don't need to use the repo: local
escape hatch as you're doing
putting all of that together, you probably want something like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install flake8-builtins
You can use flake8-builtins like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page