flake8-clean-block-0.1.2
توضیحات
A flake8 plugin that enforces a blank line after if/for/while/with/try blocks
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | flake8-clean-block-0.1.2 |
| نام | flake8-clean-block |
| نسخه کتابخانه | 0.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | https://github.com/cyyc1/flake8-clean-block |
| آدرس اینترنتی | https://pypi.org/project/flake8-clean-block/ |
| مجوز | MIT |
# flake8-clean-block
This is a [flake8](https://flake8.pycqa.org/en/latest/) plugin that enforces a blank line after `if`/`for`/`while`/`with`/`try` blocks in Python code.
## Installation
```bash
pip install flake8-clean-block
```
## Violation codes
There is one violation code that this plugin reports:
| Code | Description |
| --------- | ------------------------------------------------------ |
| CLB100 | no blank line after the end of an indented block |
## Style examples
### _Wrong_
This plugin considers the following styles wrong:
```python
for i in range(5):
print(i)
some_var = 2
```
```python
for i in range(5):
print(i)
if k == 2:
print(k)
else:
print("k")
for j in range(5):
print(j)
```
```python
for i in range(5): a += i
print(a)
```
```python
with open('filename.txt', 'r') as fp:
content = fp.readlines()
print(content)
```
### _Correct_
Correspondingly, here are the correct styles, because they are easier to read and less error-prone:
```python
for i in range(5):
print(i)
some_var = 2
```
```python
for i in range(5):
print(i)
if k == 2:
print(k)
else:
print("k")
for j in range(5):
print(j)
```
```python
for i in range(5): a += i
print(a)
```
```python
with open('filename.txt', 'r') as fp:
content = fp.readlines()
print(content)
```
## Rationale
When two lines belonging to different indentation level are right next to each other, it's difficult to read. Additionally, accidentally hitting the "tab" key on the outer line leads to subtle and hard-to-find bugs (and vice versa).
Therefore, it's better that we add at least one blank line between lines of different indentation levels.
نیازمندی
| مقدار | نام |
|---|---|
| >=4 | flake8 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl flake8-clean-block-0.1.2:
pip install flake8-clean-block-0.1.2.whl
نصب پکیج tar.gz flake8-clean-block-0.1.2:
pip install flake8-clean-block-0.1.2.tar.gz