Add flake8-bugbear

This commit is contained in:
george 2022-02-06 20:37:43 +00:00
parent 9999f7de1e
commit c415324932
No known key found for this signature in database
GPG Key ID: D30164B91DE6EEE3
11 changed files with 30 additions and 13 deletions

View File

@ -6,9 +6,7 @@ extend-ignore =
E203,
E501,
# Ignore "f-string is missing placeholders"
F541,
# allow bare "except"
E722
F541
exclude =
.git,
__pycache__,

View File

@ -4,7 +4,7 @@ repos:
hooks:
- id: black
language_version: python3.7
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8

View File

@ -440,7 +440,7 @@ def domain_detail_auto_create(custom_domain_id):
try:
re.compile(new_auto_create_rule_form.regex.data)
except:
except Exception:
flash(
f"Invalid regex {new_auto_create_rule_form.regex.data}",
"error",

View File

@ -823,7 +823,7 @@ def copy(msg: Message) -> Message:
LOG.w("deepcopy fails, try string parsing")
try:
return message_from_string(msg.as_string())
except (UnicodeEncodeError, KeyError, LookupError):
except (UnicodeEncodeError, LookupError):
LOG.w("as_string() fails, try bytes parsing")
return message_from_bytes(to_bytes(msg))

View File

@ -1323,7 +1323,7 @@ class Alias(Base, ModelMixin):
raise Exception("alias prefix cannot be empty")
# find the right suffix - avoid infinite loop by running this at max 1000 times
for i in range(1000):
for _ in range(1000):
suffix = user.get_random_alias_suffix()
email = f"{prefix}.{suffix}@{FIRST_ALIAS_DOMAIN}"

View File

@ -95,7 +95,7 @@ class SpamAssassin(object):
# join line when current one is only wrap of previous
tablelists_temp = []
if tablelists:
for counter, tablelist in enumerate(tablelists):
for _, tablelist in enumerate(tablelists):
if len(tablelist) > 1:
if (tablelist[0].isnumeric() or tablelist[0] == "-") and (
tablelist[1].isnumeric() or tablelist[1] == "."

21
poetry.lock generated
View File

@ -463,6 +463,21 @@ mccabe = ">=0.6.0,<0.7.0"
pycodestyle = ">=2.8.0,<2.9.0"
pyflakes = ">=2.4.0,<2.5.0"
[[package]]
name = "flake8-bugbear"
version = "22.1.11"
description = "A plugin for flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle."
category = "dev"
optional = false
python-versions = ">=3.6"
[package.dependencies]
attrs = ">=19.2.0"
flake8 = ">=3.0.0"
[package.extras]
dev = ["coverage", "hypothesis", "hypothesmith (>=0.2)", "pre-commit"]
[[package]]
name = "flanker"
version = "0.9.11"
@ -1941,7 +1956,7 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
content-hash = "1aefbb220007ba7c9a6ab01652e298942996f14da63fe18e13f2dfcdb15cc41c"
content-hash = "078a49e90e6d61fbb0673113c6300dd06ab5faa9a6fcc7264914fa32e21b8f5c"
[metadata.files]
aiohttp = [
@ -2224,6 +2239,10 @@ flake8 = [
{file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"},
{file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"},
]
flake8-bugbear = [
{file = "flake8-bugbear-22.1.11.tar.gz", hash = "sha256:4c2a4136bd4ecb8bf02d5159af302ffc067642784c9d0488b33ce4610da825ee"},
{file = "flake8_bugbear-22.1.11-py3-none-any.whl", hash = "sha256:ce7ae44aaaf67ef192b8a6de94a5ac617144e1675ad0654fdea556f48dc18d9b"},
]
flanker = [
{file = "flanker-0.9.11.tar.gz", hash = "sha256:974418e5b498fd3bcb3859c22e22d26495257f9cf98b744c17f2335aca86e001"},
]

View File

@ -91,8 +91,8 @@ pytest-cov = "^3.0.0"
pre-commit = "^2.17.0"
black = "^22.1.0"
flake8 = "^4.0.1"
flake8-bugbear = "^22.1.11"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View File

@ -179,7 +179,7 @@ def test_get_alias_infos_pinned_alias(flask_client):
)
# to have 3 pages: 2*PAGE_LIMIT + the alias automatically created for a new account
for i in range(2 * PAGE_LIMIT):
for _ in range(2 * PAGE_LIMIT):
Alias.create_new_random(user)
first_alias = Alias.order_by(Alias.id).first()

View File

@ -23,7 +23,7 @@ def test_too_many_requests(flask_client):
login(flask_client)
# can't create more than 5 aliases in 1 minute
for i in range(7):
for _ in range(7):
r = flask_client.post(
url_for("dashboard.index"),
data={"form-name": "create-random-email"},

View File

@ -52,7 +52,7 @@ def test_suggested_emails_for_user_who_cannot_create_new_alias(flask_client):
)
# make sure user runs out of quota to create new email
for i in range(MAX_NB_EMAIL_FREE_PLAN):
for _ in range(MAX_NB_EMAIL_FREE_PLAN):
Alias.create_new(user=user, prefix="test")
Session.commit()