Skip to content

Commit

Permalink
feat: replace re module with regex
Browse files Browse the repository at this point in the history
  • Loading branch information
4-9 committed Feb 7, 2025
1 parent 5902cbd commit 509704c
Show file tree
Hide file tree
Showing 56 changed files with 58 additions and 74 deletions.
3 changes: 1 addition & 2 deletions weblate/accounts/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations

import re

import regex as re
from django.conf import settings
from django.contrib import auth
from django.contrib.auth.decorators import login_required
Expand Down
2 changes: 1 addition & 1 deletion weblate/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from __future__ import annotations

import datetime
import re
from datetime import timedelta
from typing import TYPE_CHECKING, Literal
from urllib.parse import urlparse

import regex as re
from appconf import AppConf
from django.conf import settings
from django.contrib import admin
Expand Down
2 changes: 1 addition & 1 deletion weblate/accounts/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations

import re
import time
import unicodedata

import regex as re
from django.conf import settings
from django.http import HttpResponseRedirect
from django.shortcuts import redirect
Expand Down
2 changes: 1 addition & 1 deletion weblate/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import annotations

import os
import re
from base64 import b32encode
from binascii import unhexlify
from collections import defaultdict
Expand All @@ -16,6 +15,7 @@

import qrcode
import qrcode.image.svg
import regex as re
import social_django.utils
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
Expand Down
2 changes: 1 addition & 1 deletion weblate/addons/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Field, Layout
from django import forms
Expand Down
3 changes: 1 addition & 2 deletions weblate/addons/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

from __future__ import annotations

import re

import regex as re
from django.utils.translation import gettext_lazy

from weblate.addons.base import BaseAddon
Expand Down
11 changes: 3 additions & 8 deletions weblate/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations

import re
import uuid
from collections import defaultdict
from collections.abc import (
Iterable,
)
from collections.abc import Iterable
from functools import cache as functools_cache
from itertools import chain
from typing import TYPE_CHECKING, Any, Literal, TypedDict, cast

import regex as re
import sentry_sdk
from appconf import AppConf
from django.conf import settings
Expand Down Expand Up @@ -60,10 +58,7 @@
from weblate.utils.validators import CRUD_RE, validate_fullname, validate_username

if TYPE_CHECKING:
from collections.abc import (
Iterable,
Mapping,
)
from collections.abc import Iterable, Mapping

from social_core.backends.base import BaseAuth
from social_django.models import DjangoStorage
Expand Down
3 changes: 1 addition & 2 deletions weblate/checks/angularjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from __future__ import annotations

import re

import regex as re
from django.utils.translation import gettext_lazy

from .format import BaseFormatCheck
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any, TypedDict

import regex as re
import sentry_sdk
from django.http import Http404
from django.utils.html import format_html, format_html_join
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/chars.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from __future__ import annotations

import re
import unicodedata
from typing import TYPE_CHECKING

import regex as re
from django.utils.translation import gettext_lazy

from weblate.checks.base import CountingCheck, TargetCheck, TargetCheckParametrized
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.html import format_html
from django.utils.translation import gettext_lazy

Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from __future__ import annotations

import re
from functools import lru_cache
from typing import TYPE_CHECKING, Any, cast

import regex as re
from django.core.exceptions import ValidationError
from django.utils.translation import gettext, gettext_lazy
from lxml import etree
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/fluent/inner_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from __future__ import annotations

import html
import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.translation import gettext, gettext_lazy

from weblate.checks.base import SourceCheck, TargetCheck
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/fluent/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.translation import gettext, gettext_lazy

from weblate.checks.base import TargetCheck
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/fluent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.html import escape, format_html, format_html_join
from django.utils.safestring import mark_safe
from translate.storage.fluent import (
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from __future__ import annotations

import re
from collections import Counter, defaultdict
from re import Pattern
from typing import TYPE_CHECKING, Literal

import regex as re
from django.utils.functional import SimpleLazyObject
from django.utils.html import format_html, format_html_join
from django.utils.safestring import mark_safe
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.html import escape, format_html, format_html_join
from django.utils.translation import gettext, gettext_lazy

Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from __future__ import annotations

import re
from collections import Counter, defaultdict
from functools import cache, lru_cache
from itertools import chain
from typing import TYPE_CHECKING

import regex as re
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.utils.functional import cached_property
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
import threading

import regex as re
from pyparsing import Optional, ParserElement, QuotedString, Regex, ZeroOrMore


Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING, Any, Literal

import regex as re
from django.utils.functional import SimpleLazyObject
from django.utils.html import escape, format_html, format_html_join
from django.utils.safestring import mark_safe
Expand Down
3 changes: 1 addition & 2 deletions weblate/checks/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

import re

import regex as re
from django.utils.translation import gettext_lazy

from weblate.checks.format import BaseFormatCheck
Expand Down
3 changes: 1 addition & 2 deletions weblate/checks/ruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

import re

import regex as re
from django.utils.translation import gettext_lazy

from weblate.checks.format import BaseFormatCheck
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/same.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.utils.html import strip_tags
from django.utils.translation import gettext_lazy
from weblate_language_data.check_languages import LANGUAGES
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from __future__ import annotations

import re
from collections import defaultdict
from datetime import timedelta
from typing import TYPE_CHECKING

import regex as re
from django.utils import timezone
from django.utils.html import format_html_join
from django.utils.safestring import mark_safe
Expand Down
2 changes: 1 addition & 1 deletion weblate/checks/tests/test_fluent_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from __future__ import annotations

import itertools
import re
from typing import TYPE_CHECKING

import regex as re
from django.test import SimpleTestCase

from weblate.checks.flags import Flags
Expand Down
2 changes: 1 addition & 1 deletion weblate/formats/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from __future__ import annotations

import re
from itertools import chain

import regex as re
from django.utils.translation import gettext_lazy
from lxml.etree import XMLSyntaxError
from translate.misc.multistring import multistring
Expand Down
2 changes: 1 addition & 1 deletion weblate/formats/ttkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import importlib
import inspect
import os
import re
import subprocess
from typing import TYPE_CHECKING, Any, BinaryIO

import regex as re
from django.core.exceptions import ValidationError
from django.utils.functional import cached_property
from django.utils.translation import gettext, gettext_lazy
Expand Down
2 changes: 1 addition & 1 deletion weblate/glossary/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from __future__ import annotations

import re
import sys
import unicodedata
from collections import defaultdict
from itertools import chain

import ahocorasick_rs
import regex as re
import sentry_sdk
from django.core.cache import cache
from django.db.models import Prefetch, Q, Value
Expand Down
2 changes: 1 addition & 1 deletion weblate/lang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from __future__ import annotations

import re
from collections import defaultdict
from gettext import c2py
from itertools import chain
from operator import itemgetter
from typing import TYPE_CHECKING
from weakref import WeakValueDictionary

import regex as re
from appconf import AppConf
from django.conf import settings
from django.contrib.admin.utils import NestedObjects
Expand Down
2 changes: 1 addition & 1 deletion weblate/legal/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from __future__ import annotations

import re
from typing import TYPE_CHECKING

import regex as re
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.http import urlencode
Expand Down
2 changes: 1 addition & 1 deletion weblate/machinery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

import random
import re
import time
from collections import defaultdict
from collections.abc import Iterable, Iterator
Expand All @@ -17,6 +16,7 @@
from typing import TYPE_CHECKING, NotRequired, TypedDict
from urllib.parse import quote

import regex as re
from django.core.cache import cache
from django.core.exceptions import ValidationError
from django.utils.functional import cached_property
Expand Down
2 changes: 1 addition & 1 deletion weblate/machinery/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later

import json
import re

import regex as re
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import gettext, gettext_lazy, pgettext_lazy
Expand Down
Loading

0 comments on commit 509704c

Please sign in to comment.