flake8

Descriptive flake8 errors in PyCharm

我是研究僧i 提交于 2020-06-09 17:06:30
问题 PyCharm does not have a built-in support for flake8 at the moment. But, flake8 can be configured to run as an external tool. Sometimes, especially for Python newcomers, not every flake8 warning is understandable and additional clarification is required. We've recently stumbled upon the Flake8Rules project which attempts to describe every single warning in a detailed way with supportive examples. Is there a way to combine PyCharm, flake8 and Flake8Rules altogether to have static code analysis

How to install Python (dev) dependencies globally so that I don't have to reinstall them in every venv?

匆匆过客 提交于 2020-04-30 08:47:15
问题 There are a few Python dependencies that I would like to be available in every venv (virtual environment) that I create for each project. For example black, flake8 and pytest. Is that possible and if so, how to achieve that? I'd like to install these three once under my main Python installation, instead I have to reinstall all of them in every venv that I create when I start a new project. This is specially annoying when using VSCode which throws popups complaining about "Linter flake8 is not

How to install Python (dev) dependencies globally so that I don't have to reinstall them in every venv?

半世苍凉 提交于 2020-04-30 08:46:11
问题 There are a few Python dependencies that I would like to be available in every venv (virtual environment) that I create for each project. For example black, flake8 and pytest. Is that possible and if so, how to achieve that? I'd like to install these three once under my main Python installation, instead I have to reinstall all of them in every venv that I create when I start a new project. This is specially annoying when using VSCode which throws popups complaining about "Linter flake8 is not

python pep8 class in init imported but not used

ぃ、小莉子 提交于 2020-02-17 08:26:13
问题 I'm doing PEP8 checks in python using the python flake8 library. I have an import statement in an __init__.py file in one of my sub-modules which looks like this: from .my_class import MyClass The reason I have this line in the init file is so that I can import MyClass from the sub-module as from somemodule import MyClass instead of having to write from somemodule.my_class import MyClass . I would like to know if it is possible to maintain this functionality while correcting the PEP8

flake8 max-complexity per file

百般思念 提交于 2020-01-26 03:52:05
问题 I have a legacy project using flake8 to check code quality and complexity, but the project has some very complicated (terrible) services which are returning complexity WARNING messages: ./service1.py:127:1: C901 'some_method' is too complex (50) We are slowly transitioning into making them better, but we need to make jenkins (which is running tests and flake8) pass. Is there a way to specify ignoring a code error or complexity per file, or even per method? 回答1: You can use flake8-per-file

How to avoid flake8's “F821 undefined name '_'” when _ has been installed by gettext?

本秂侑毒 提交于 2020-01-03 08:30:22
问题 Problem overview: In my project's main script, gettext installs the function _() that is used in other modules for translations (like in print(_('Something to translate')) ). As stated by the doc: the _() function [is] installed in Python’s builtins namespace, so it is easily accessible in all modules of your application. So, everything runs fine. Only problem : flake8 shows errors (actually returned by PyFlakes): $ flake8 *.py lib.py:2:12: F821 undefined name '_' main_script.py:8:7: F821

Unicode Error when running Flake8 test with TOX

雨燕双飞 提交于 2020-01-02 07:12:21
问题 I'm new to Tox and i want to set it up to run flake8 test on my project but i keep getting unicode error when i try to run tox. UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 76: ordinal not in range(128) This is a peek of my tox.ini file: [tox] envlist = flake8 [testenv:flake8] basepython = python2 skip_install = true deps = flake8 commands = flake8 -v # Flake8 Configuration [flake8] # Ignore some flake8-docstrings errors # NOTE(sigmavirus24): While we're still using

flake8 not picking up config file

隐身守侯 提交于 2019-12-23 08:57:43
问题 I have my flake8 config file in ~/.config/flake8 [flake8] max-line-length = 100 However when I run flake8 the config file is not picked up. I know that because i still get warnings over lines longer than 79 char. I'm on redhat, but the same happens on mac. I use pyenv. Global is 2.7.6 (not even sure this is relevant) 回答1: This was caused by a regression in pep8 1.6.1 and is resolved in the just released 1.6.2 version. 来源: https://stackoverflow.com/questions/28436382/flake8-not-picking-up

How do I enable auto code formatting for flake8 in PyCharm

你说的曾经没有我的故事 提交于 2019-12-22 02:05:42
问题 I use Tox to run unit tests, with a flake8 command that checks for code formatting errors. Each time I code in PyCharm, I run tox then realise I have a bunch of annoying formatting errors I have to back and manually fix. I would like PyCharm to automatically format the code (according to flake8 google for me each time it auto-saves after I stop typing. my tox testenv looks like this: [testenv:flake8] commands=flake8 <my_code_directory> deps = flake8==2.4.1 flake8-import-order==0.11 pep8

How do I get Flake8 to work with F811 errors?

本秂侑毒 提交于 2019-12-21 17:39:15
问题 We're using flake8 to test our code, and we're using pytest with fixtures. The following code: from staylists.tests.fixtures import fixture1 # noqa: F401 def test_case(fixture1): # noqa: F811 # Test goes here assert 1 == 1 Generates a lib/python/test.py:3:1: F811 redefinition of unused 'fixture1' from line 1 error during linting. Why does it ignore the noqa flag? Is there a better way to avoid flagging this error? 回答1: The F401 and F811 errors can be avoided by moving all fixtures into the