Skip to content

Commit 0a53f2d

Browse files
committed
chore: fix linting error
Fix or override issues found by linters.
1 parent 9598107 commit 0a53f2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+340
-254
lines changed

pyproject.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ max_allowed_size_uncompressed = '300M'
429429
[tool.pylint.main]
430430
disable = [
431431
"abstract-method", # TODO
432-
"arguments-differ", # TODO
433-
"arguments-renamed", # TODO
434432
"attribute-defined-outside-init", # TODO
435433
"broad-exception-caught", # TODO
436434
"c-extension-no-member",
@@ -443,7 +441,7 @@ disable = [
443441
"import-outside-toplevel",
444442
"invalid-name", # TODO
445443
"invalid-overridden-method", # TODO
446-
"invalid-str-returned",
444+
"invalid-str-returned", # Most of Django __str__ fails this
447445
"keyword-arg-before-vararg", # TODO
448446
"line-too-long",
449447
"missing-class-docstring",
@@ -456,8 +454,6 @@ disable = [
456454
"not-callable",
457455
"protected-access", # TODO
458456
"raising-bad-type",
459-
"redefined-builtin", # TODO
460-
"redefined-outer-name", # TODO
461457
"too-few-public-methods",
462458
"too-many-ancestors",
463459
"too-many-arguments",
@@ -471,7 +467,6 @@ disable = [
471467
"too-many-public-methods",
472468
"too-many-return-statements",
473469
"too-many-statements",
474-
"unspecified-encoding", # TODO
475470
"unsubscriptable-object",
476471
"unsupported-assignment-operation", # TODO
477472
"unsupported-binary-operation",
@@ -577,7 +572,6 @@ ignore = [
577572
"PLC0415", # TODO: `import` should be at the top-level of a file
578573
"PLR2004", # TODO: Magic value used in comparison, consider replacing 201 with a constant variable
579574
"PLR6301", # TODO: Method could be a function, class method, or static method
580-
"PLW1514", # TODO: `open` in text mode without explicit `encoding` argument
581575
"PLW2901", # TODO: overwriting variables inside loop
582576
"PT", # CONFIG: Not using pytest
583577
"PTH", # TODO: Not using pathlib

scripts/extract-release-notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
tag = f'<section id="weblate-{version}">.+?<h1>(.+?)<a(.+?)</a></h1>(.+?)</section>'
1818

19-
data = Path("docs/_build/html/changes.html").read_text()
19+
data = Path("docs/_build/html/changes.html").read_text(encoding="utf-8")
2020

2121
for match in re.findall(tag, data, re.MULTILINE | re.DOTALL):
2222
print(match[0])

scripts/generate-license-data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,18 @@ def escape_string(string: str) -> str:
4949
"Beerware",
5050
}
5151

52-
with open("scripts/spdx-license-list/json/licenses.json") as handle:
52+
with open("scripts/spdx-license-list/json/licenses.json", encoding="utf-8") as handle:
5353
data = json.load(handle)
5454

55-
with open("weblate/utils/licensedata.py", "w") as output:
55+
with open("weblate/utils/licensedata.py", "w", encoding="utf-8") as output:
5656
output.write(HEADER)
5757
output.write("LICENSES = (\n")
5858
for item in sorted(data["licenses"], key=lambda x: x["name"].lower()):
5959
if item["isDeprecatedLicenseId"]:
6060
continue
6161
with open(
62-
f"scripts/spdx-license-list/json/details/{item['licenseId']}.json"
62+
f"scripts/spdx-license-list/json/details/{item['licenseId']}.json",
63+
encoding="utf-8",
6364
) as handle:
6465
details = json.load(handle)
6566
libre = (

scripts/generate-specialchars.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@
377377

378378

379379
# Parse CSV passed on the command line
380-
with open(sys.argv[1]) as handle:
380+
with open(sys.argv[1], encoding="utf-8") as handle:
381381
for (
382382
pos,
383383
_change,

scripts/reproducible-sbom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def generate_uuid(payload: str) -> UUID:
2727
sys.exit(1)
2828

2929
filename = sys.argv[1]
30-
with open(filename) as handle:
30+
with open(filename, encoding="utf-8") as handle:
3131
data = json.load(handle)
3232

3333
# Remove varying fields
@@ -41,6 +41,6 @@ def generate_uuid(payload: str) -> UUID:
4141
# Update serial number
4242
data["serialNumber"] = f"urn:uuid:{reproducible_uuid}"
4343

44-
with open(filename, "w") as handle:
44+
with open(filename, "w", encoding="utf-8") as handle:
4545
json.dump(data, handle, indent=2)
4646
handle.write("\n")

scripts/set-version.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222

2323

2424
def replace_file(name: str, search: str, replace: str) -> None:
25-
content = Path(name).read_text()
25+
content = Path(name).read_text(encoding="utf-8")
2626

2727
content = re.sub(search, replace, content, flags=re.MULTILINE)
28-
Path(name).write_text(content)
28+
Path(name).write_text(content, encoding="utf-8")
2929

3030

3131
def prepend_file(name: str, content: str) -> None:
32-
content += Path(name).read_text()
33-
Path(name).write_text(content)
32+
content += Path(name).read_text(encoding="utf-8")
33+
Path(name).write_text(content, encoding="utf-8")
3434

3535

3636
yaml = YAML()

weblate/accounts/avatar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from django.utils.translation import gettext, pgettext
1919

2020
from weblate.utils.errors import report_error
21-
from weblate.utils.requests import request
21+
from weblate.utils.requests import http_request
2222

2323
if TYPE_CHECKING:
2424
from weblate.auth.models import User
@@ -77,7 +77,7 @@ def get_avatar_image(user: User, size: int) -> bytes:
7777
def download_avatar_image(email: str, size: int) -> bytes:
7878
"""Download avatar image from remote server."""
7979
url = avatar_for_email(email, size)
80-
response = request("get", url, timeout=1.0)
80+
response = http_request("get", url, timeout=1.0)
8181
return response.content
8282

8383

weblate/accounts/forms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ class SetPasswordForm(DjangoSetPasswordForm):
707707
)
708708

709709
@transaction.atomic
710+
# pylint: disable-next=arguments-renamed
710711
def save(self, request: AuthenticatedHttpRequest, delete_session=False) -> None:
711712
AuditLog.objects.create(
712713
self.user,

weblate/accounts/management/commands/importuserdata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def handle_compat(self, data) -> None:
6262
"watched": data["subscriptions"],
6363
}
6464

65+
# pylint: disable-next=arguments-differ
6566
def handle(self, **options) -> None:
6667
"""
6768
Create default set of groups.

weblate/accounts/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from weblate.trans.defines import FULLNAME_LENGTH
3434
from weblate.utils import messages
3535
from weblate.utils.ratelimit import reset_rate_limit
36-
from weblate.utils.requests import request
36+
from weblate.utils.requests import http_request
3737
from weblate.utils.validators import (
3838
CRUD_RE,
3939
USERNAME_MATCHER,
@@ -55,7 +55,7 @@ class EmailAlreadyAssociated(AuthAlreadyAssociated):
5555

5656
def get_github_emails(access_token):
5757
"""Get real e-mail from GitHub."""
58-
response = request(
58+
response = http_request(
5959
"get",
6060
"https://api.github.com/user/emails",
6161
headers={"Authorization": f"token {access_token}"},

0 commit comments

Comments
 (0)