Skip to content

Commit

Permalink
Bump minor deps (#319)
Browse files Browse the repository at this point in the history
* Bump minor deps

* Formatting

* Fix linter issues

- Update make format task to check for all selected linter categories
  • Loading branch information
whabanks authored Sep 10, 2024
1 parent 850e117 commit 8dcaedd
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/actions/waffles/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
docopt==0.6.2
Flask==2.3.3
markupsafe==2.1.5
git+https://github.com/cds-snc/[email protected].1#egg=notifications-utils
git+https://github.com/cds-snc/[email protected].2#egg=notifications-utils
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ clean-docker-containers: ## Clean up any remaining docker containers
format:
ruff check --select I --fix .
ruff format .
ruff check
poetry run mypy .
poetry sort

Expand Down
3 changes: 2 additions & 1 deletion notifications_utils/clients/redis/bounce_rate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module is used to calculate the bounce rate for a service. It uses Redis to store the total number of hard bounces """
"""This module is used to calculate the bounce rate for a service. It uses Redis to store the total number of hard bounces"""

from datetime import datetime

from notifications_utils.clients.redis.redis_client import RedisClient
Expand Down
12 changes: 6 additions & 6 deletions notifications_utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
LINK_STYLE = "word-wrap: break-word;"

OBSCURE_WHITESPACE = (
"\u180E" # Mongolian vowel separator
"\u200B" # zero width space
"\u200C" # zero width non-joiner
"\u200D" # zero width joiner
"\u180e" # Mongolian vowel separator
"\u200b" # zero width space
"\u200c" # zero width non-joiner
"\u200d" # zero width joiner
"\u2060" # word joiner
"\uFEFF" # zero width non-breaking space
"\ufeff" # zero width non-breaking space
)

EMAIL_P_OPEN_TAG = '<p style="Margin: 0 0 20px 0; font-size: 19px; line-height: 25px; color: #0B0C0C;">'
Expand Down Expand Up @@ -85,7 +85,7 @@


def unlink_govuk_escaped(message):
return re.sub(govuk_not_a_link, r"\1" + ".\u200B" + r"\2", message) # Unicode zero-width space
return re.sub(govuk_not_a_link, r"\1" + ".\u200b" + r"\2", message) # Unicode zero-width space


def nl2br(value):
Expand Down
4 changes: 2 additions & 2 deletions notifications_utils/sanitise_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class SanitiseText:
"’": "'", # RIGHT SINGLE QUOTATION MARK (U+2019)
"“": '"', # LEFT DOUBLE QUOTATION MARK (U+201C)
"”": '"', # RIGHT DOUBLE QUOTATION MARK (U+201D)
"\u200B": "", # ZERO WIDTH SPACE (U+200B)
"\u00A0": "", # NON BREAKING WHITE SPACE (U+200B)
"\u200b": "", # ZERO WIDTH SPACE (U+200B)
"\u00a0": "", # NON BREAKING WHITE SPACE (U+200B)
"\t": " ", # TAB
}

Expand Down
28 changes: 14 additions & 14 deletions notifications_utils/strftime_codes.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""This module provides platform compatible format codes for strftime.
By default, Python does not check the format codes sent to strftime:
these are sent directly to the platform's implementation. This leads
developers to use platform specific format codes for strftime that
can't easily run on other platforms that are popular and normally
easy to support for by the Python language.
By default, Python does not check the format codes sent to strftime:
these are sent directly to the platform's implementation. This leads
developers to use platform specific format codes for strftime that
can't easily run on other platforms that are popular and normally
easy to support for by the Python language.
Hence we have this module that makes the translation between platform
specific format codes. To refer to the different platform specific
codes and what is deemed safe (i.e. ANSI C/ POSIX compatible):
Hence we have this module that makes the translation between platform
specific format codes. To refer to the different platform specific
codes and what is deemed safe (i.e. ANSI C/ POSIX compatible):
For windows, see:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?redirectedfrom=MSDN&view=msvc-160
For windows, see:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?redirectedfrom=MSDN&view=msvc-160
For *nix compatible (non-POSIX compatible), see:
https://man7.org/linux/man-pages/man3/strftime.3.html
For *nix compatible (non-POSIX compatible), see:
https://man7.org/linux/man-pages/man3/strftime.3.html
'somewhat POSIX'/ ANSI C compatible, see
https://en.cppreference.com/w/c/chrono/strftime
'somewhat POSIX'/ ANSI C compatible, see
https://en.cppreference.com/w/c/chrono/strftime
"""

import platform
Expand Down
59 changes: 30 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "notifications-utils"
version = "52.3.1"
version = "52.3.2"
description = "Shared python code for Notification - Provides logging utils etc."
authors = ["Canadian Digital Service"]
license = "MIT license"
Expand Down Expand Up @@ -30,7 +30,7 @@ markupsafe = "2.1.5"
mistune = "0.8.4"
ordered-set = "4.1.0"
phonenumbers = "8.13.42"
pre-commit = "^3.7.1"
pre-commit = "^3.8.0"
py_w3c = "0.3.1"
pypdf2 = "1.28.6"
python-json-logger = "2.0.7"
Expand All @@ -44,18 +44,18 @@ werkzeug = "3.0.3"
[tool.poetry.group.test.dependencies]
beautifulsoup4 = "^4.12.3"
click = "8.1.7"
fakeredis = "^2.10.3"
fakeredis = "^2.24.1"
freezegun = "1.5.1"
mypy = "1.10.0"
pytest = "7.4.4"
pytest-cov = "2.12.1"
pytest-mock = "3.14.0"
pytest-xdist = "2.5.0"
requests-mock = "1.12.1"
ruff = "^0.2.1"
ruff = "^0.6.0"
types-beautifulsoup4 = "^4.12.0.20240229"
types-bleach = "5.0.3.1"
types-cachetools = "5.3.0.7"
types-cachetools = "5.5.0.20240820"
types-python-dateutil = "2.9.0.20240316"
types-pytz = "2022.7.1.2"
types-PyYAML = "6.0.12.20240724"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def test_preserves_whitespace_when_making_links(markdown_function, expected_outp
@pytest.mark.parametrize(
"template_content,expected",
[
("gov.uk", "gov.\u200Buk"),
("GOV.UK", "GOV.\u200BUK"),
("Gov.uk", "Gov.\u200Buk"),
("gov.uk", "gov.\u200buk"),
("GOV.UK", "GOV.\u200bUK"),
("Gov.uk", "Gov.\u200buk"),
("https://gov.uk", "https://gov.uk"),
("https://www.gov.uk", "https://www.gov.uk"),
("www.gov.uk", "www.gov.uk"),
Expand Down Expand Up @@ -951,7 +951,7 @@ def test_make_list_from_linebreaks():
"""
\t bar
""",
" \u180E\u200B \u200C bar \u200D \u2060\uFEFF ",
" \u180e\u200b \u200c bar \u200d \u2060\ufeff ",
],
)
def test_strip_whitespace(value):
Expand All @@ -963,7 +963,7 @@ def test_strip_whitespace(value):
[
"notifications-email",
" \tnotifications-email \x0c ",
"\rn\u200Coti\u200Dfi\u200Bcati\u2060ons-\u180Eemai\uFEFFl\uFEFF",
"\rn\u200coti\u200dfi\u200bcati\u2060ons-\u180eemai\ufeffl\ufeff",
],
)
def test_strip_and_remove_obscure_whitespace(value):
Expand Down Expand Up @@ -996,7 +996,7 @@ def test_strip_unsupported_characters():


def test_normalise_whitespace():
assert normalise_whitespace("\u200C Your tax is\ndue\n\n") == "Your tax is due"
assert normalise_whitespace("\u200c Your tax is\ndue\n\n") == "Your tax is due"


class TestAddLanguageDivs:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class App:
handlers = logging.get_handlers(app)

assert len(handlers) == 1
assert type(handlers[0]) == builtin_logging.StreamHandler
assert type(handlers[0].formatter) == logging.CustomLogFormatter
assert type(handlers[0]) is builtin_logging.StreamHandler
assert type(handlers[0].formatter) is logging.CustomLogFormatter
assert not (tmpdir / "foo").exists()


Expand All @@ -85,8 +85,8 @@ class App:
handlers = logging.get_handlers(app)

assert len(handlers) == 1
assert type(handlers[0]) == builtin_logging.StreamHandler
assert type(handlers[0].formatter) == logging.JSONFormatter
assert type(handlers[0]) is builtin_logging.StreamHandler
assert type(handlers[0].formatter) is logging.JSONFormatter

# assert type(handlers[1]) == builtin_logging_handlers.WatchedFileHandler
# assert type(handlers[1].formatter) == logging.JSONFormatter
Expand Down
12 changes: 6 additions & 6 deletions tests/test_recipient_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,14 +844,14 @@ def test_ignores_spaces_and_case_in_placeholders(key, expected):
("\n", None), # newline
("\r", None), # carriage return
("\t", None), # tab
("\u180E", "MONGOLIAN VOWEL SEPARATOR"),
("\u200B", "ZERO WIDTH SPACE"),
("\u200C", "ZERO WIDTH NON-JOINER"),
("\u200D", "ZERO WIDTH JOINER"),
("\u180e", "MONGOLIAN VOWEL SEPARATOR"),
("\u200b", "ZERO WIDTH SPACE"),
("\u200c", "ZERO WIDTH NON-JOINER"),
("\u200d", "ZERO WIDTH JOINER"),
("\u2060", "WORD JOINER"),
("\uFEFF", "ZERO WIDTH NO-BREAK SPACE"),
("\ufeff", "ZERO WIDTH NO-BREAK SPACE"),
# all the things
(" \n\r\t\u000A\u000D\u180E\u200B\u200C\u200D\u2060\uFEFF", None),
(" \n\r\t\u000a\u000d\u180e\u200b\u200c\u200d\u2060\ufeff", None),
),
)
def test_ignores_leading_whitespace_in_file(character, name):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_recipient_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_validate_email_address_accepts_valid(email_address):
" [email protected] ",
"\t[email protected]",
"\t[email protected]\n",
"\u200Bemail@domain.com\u200B",
"\u200bemail@domain.com\u200b",
],
)
def test_validate_email_address_strips_whitespace(email):
Expand Down Expand Up @@ -400,7 +400,7 @@ def test_validate_address_allows_any_non_empty_value(column):
],
)
def test_non_ascii_address_line_is_fine(column):
valid_address = "\u041F\u0435\u0442\u044F"
valid_address = "\u041f\u0435\u0442\u044f"
assert validate_recipient(valid_address, "letter", column=column) == valid_address


Expand Down
2 changes: 1 addition & 1 deletion tests/test_sanitise_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_encode_chars_sms_fr_not_downgraded(chars, cls):
(("–", "-"), "compatibility transform unicode char (EN DASH (U+2013)"),
(("—", "-"), "compatibility transform unicode char (EM DASH (U+2014)"),
(("…", "..."), "compatibility transform unicode char (HORIZONTAL ELLIPSIS (U+2026)"),
(("\u200B", ""), "compatibility transform unicode char (ZERO WIDTH SPACE (U+200B)"),
(("\u200b", ""), "compatibility transform unicode char (ZERO WIDTH SPACE (U+200B)"),
(("‘", "'"), "compatibility transform unicode char (LEFT SINGLE QUOTATION MARK (U+2018)"),
(("’", "'"), "compatibility transform unicode char (RIGHT SINGLE QUOTATION MARK (U+2019)"),
(("“", '"'), "compatibility transform unicode char (LEFT DOUBLE QUOTATION MARK (U+201C) "),
Expand Down
8 changes: 4 additions & 4 deletions tests/test_template_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ def test_HTML_template_has_URLs_replaced_with_links(content, html_snippet):
@pytest.mark.parametrize(
"template_content,expected",
[
("gov.uk", "gov.\u200Buk"),
("GOV.UK", "GOV.\u200BUK"),
("Gov.uk", "Gov.\u200Buk"),
("gov.uk", "gov.\u200buk"),
("GOV.UK", "GOV.\u200bUK"),
("Gov.uk", "Gov.\u200buk"),
("https://gov.uk", "https://gov.uk"),
("https://www.gov.uk", "https://www.gov.uk"),
("www.gov.uk", "www.gov.uk"),
Expand Down Expand Up @@ -2064,7 +2064,7 @@ def test_whitespace_in_subjects(template_class, subject, extra_args):
)
def test_whitespace_in_subject_placeholders(template_class):
assert (
template_class({"content": "", "subject": "\u200C Your tax ((status))"}, values={"status": " is\ndue "}).subject
template_class({"content": "", "subject": "\u200c Your tax ((status))"}, values={"status": " is\ndue "}).subject
== "Your tax is due"
)

Expand Down

0 comments on commit 8dcaedd

Please sign in to comment.