diff --git a/docs/conf_base.py b/docs/conf_base.py index 92997d6..affc125 100644 --- a/docs/conf_base.py +++ b/docs/conf_base.py @@ -50,8 +50,8 @@ master_doc = 'index' # General information about the project. -project = u'python-emails' -copyright = u'2015-2026, Sergey Lavrinenko' +project = 'python-emails' +copyright = '2015-2026, Sergey Lavrinenko' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -216,8 +216,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'python-emails.tex', u'python-emails Documentation', - u'Sergey Lavrinenko', 'manual'), + ('index', 'python-emails.tex', 'python-emails Documentation', + 'Sergey Lavrinenko', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -246,8 +246,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'python-emails', u'python-emails Documentation', - [u'Sergey Lavrinenko'], 1) + ('index', 'python-emails', 'python-emails Documentation', + ['Sergey Lavrinenko'], 1) ] # If true, show URL addresses after external links. @@ -260,8 +260,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'python-emails', u'python-emails Documentation', - u'Sergey Lavrinenko', 'python-emails', 'One line description of project.', + ('index', 'python-emails', 'python-emails Documentation', + 'Sergey Lavrinenko', 'python-emails', 'One line description of project.', 'Miscellaneous'), ] diff --git a/emails/__init__.py b/emails/__init__.py index 57e8a20..772c9de 100644 --- a/emails/__init__.py +++ b/emails/__init__.py @@ -1,4 +1,3 @@ -# coding: utf-8 """ python-emails ~~~~~~~~~~~~~ diff --git a/emails/backend/__init__.py b/emails/backend/__init__.py index c9b16aa..3952de5 100644 --- a/emails/backend/__init__.py +++ b/emails/backend/__init__.py @@ -1,3 +1,2 @@ -# encoding: utf-8 from .factory import ObjectFactory from .smtp import SMTPBackend diff --git a/emails/backend/factory.py b/emails/backend/factory.py index fab0df0..17a712a 100644 --- a/emails/backend/factory.py +++ b/emails/backend/factory.py @@ -1,4 +1,3 @@ -# encoding: utf-8 def simple_dict2str(d): # Simple dict serializer diff --git a/emails/backend/inmemory/__init__.py b/emails/backend/inmemory/__init__.py index 5f24697..9ff0c03 100644 --- a/emails/backend/inmemory/__init__.py +++ b/emails/backend/inmemory/__init__.py @@ -1,4 +1,3 @@ -# encoding: utf-8 __all__ = ['InMemoryBackend', ] diff --git a/emails/backend/response.py b/emails/backend/response.py index dd10832..63748fd 100644 --- a/emails/backend/response.py +++ b/emails/backend/response.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations from typing import Any diff --git a/emails/backend/smtp/__init__.py b/emails/backend/smtp/__init__.py index 5269652..9988a73 100644 --- a/emails/backend/smtp/__init__.py +++ b/emails/backend/smtp/__init__.py @@ -1,3 +1,2 @@ -# encoding: utf-8 from .backend import SMTPBackend \ No newline at end of file diff --git a/emails/backend/smtp/backend.py b/emails/backend/smtp/backend.py index 3f7231d..0b2500e 100644 --- a/emails/backend/smtp/backend.py +++ b/emails/backend/smtp/backend.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations import logging diff --git a/emails/backend/smtp/client.py b/emails/backend/smtp/client.py index 3798c06..0aa59d7 100644 --- a/emails/backend/smtp/client.py +++ b/emails/backend/smtp/client.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations __all__ = ['SMTPClientWithResponse', 'SMTPClientWithResponse_SSL'] diff --git a/emails/backend/smtp/exceptions.py b/emails/backend/smtp/exceptions.py index a747aec..49e68c6 100644 --- a/emails/backend/smtp/exceptions.py +++ b/emails/backend/smtp/exceptions.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import socket diff --git a/emails/django/__init__.py b/emails/django/__init__.py index 1594643..9bcf8c8 100644 --- a/emails/django/__init__.py +++ b/emails/django/__init__.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from django.core.mail import get_connection from .. message import MessageTransformerMixin, MessageSignMixin, MessageBuildMixin, BaseMessage from .. utils import sanitize_email diff --git a/emails/django_.py b/emails/django_.py index cad8e6a..4534995 100644 --- a/emails/django_.py +++ b/emails/django_.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import warnings warnings.warn("emails.django_ module moved to emails.django", DeprecationWarning) diff --git a/emails/exc.py b/emails/exc.py index 476b566..f091139 100644 --- a/emails/exc.py +++ b/emails/exc.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations from .packages.dkim import DKIMException diff --git a/emails/loader/__init__.py b/emails/loader/__init__.py index eb8ca3a..de8eb3d 100644 --- a/emails/loader/__init__.py +++ b/emails/loader/__init__.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import os.path from email.utils import formataddr diff --git a/emails/loader/helpers.py b/emails/loader/helpers.py index 7147417..c9f688e 100644 --- a/emails/loader/helpers.py +++ b/emails/loader/helpers.py @@ -1,4 +1,3 @@ -# encoding: utf-8 __all__ = ['guess_charset', 'fix_content_type'] from email.message import Message diff --git a/emails/loader/local_store.py b/emails/loader/local_store.py index 646f783..2c39bc5 100644 --- a/emails/loader/local_store.py +++ b/emails/loader/local_store.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from email.utils import parseaddr import logging import mimetypes diff --git a/emails/message.py b/emails/message.py index 15c39fe..f2ce6a0 100644 --- a/emails/message.py +++ b/emails/message.py @@ -1,4 +1,3 @@ -# coding: utf-8 from __future__ import annotations from collections.abc import Callable diff --git a/emails/signers.py b/emails/signers.py index 71c8365..a3b77d4 100644 --- a/emails/signers.py +++ b/emails/signers.py @@ -1,4 +1,3 @@ -# encoding: utf-8 # This module use pydkim for DKIM signature from __future__ import annotations diff --git a/emails/store/file.py b/emails/store/file.py index 1fbc0f5..5a2ff9a 100644 --- a/emails/store/file.py +++ b/emails/store/file.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations import uuid diff --git a/emails/store/store.py b/emails/store/store.py index ae6e4c1..934657e 100644 --- a/emails/store/store.py +++ b/emails/store/store.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from __future__ import annotations from collections import OrderedDict diff --git a/emails/template/base.py b/emails/template/base.py index 7b9976c..e521cdc 100644 --- a/emails/template/base.py +++ b/emails/template/base.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import string diff --git a/emails/template/jinja_template.py b/emails/template/jinja_template.py index 8a31d88..51d608f 100644 --- a/emails/template/jinja_template.py +++ b/emails/template/jinja_template.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from .base import BaseTemplate diff --git a/emails/template/mako_template.py b/emails/template/mako_template.py index c8b7208..9ac61a2 100644 --- a/emails/template/mako_template.py +++ b/emails/template/mako_template.py @@ -1,4 +1,3 @@ -# encoding: utf-8 from .base import BaseTemplate diff --git a/emails/testsuite/conftest.py b/emails/testsuite/conftest.py index 3fb2949..5269a51 100644 --- a/emails/testsuite/conftest.py +++ b/emails/testsuite/conftest.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import logging import datetime import pytest diff --git a/emails/testsuite/django_/test_django_integrations.py b/emails/testsuite/django_/test_django_integrations.py index f8e43bb..006a64e 100644 --- a/emails/testsuite/django_/test_django_integrations.py +++ b/emails/testsuite/django_/test_django_integrations.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import warnings import emails import emails.message diff --git a/emails/testsuite/loader/test_helpers.py b/emails/testsuite/loader/test_helpers.py index ab24b2a..44c222f 100644 --- a/emails/testsuite/loader/test_helpers.py +++ b/emails/testsuite/loader/test_helpers.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import logging; import cssutils; cssutils.log.setLevel(logging.FATAL) @@ -33,16 +32,16 @@ def norma_enc(enc): assert enc_ return enc_ - assert decode_text(u'A')[0] == u'A' - assert decode_text(b'A') == (u'A', 'ascii') + assert decode_text('A')[0] == 'A' + assert decode_text(b'A') == ('A', 'ascii') for enc in ['utf-8', 'windows-1251', 'cp866']: - t = u'Шла Саша по шоссе и сосала сушку. В огороде бузина, в Киеве дядька.' + t = 'Шла Саша по шоссе и сосала сушку. В огороде бузина, в Киеве дядька.' text, guessed_encoding = decode_text(t.encode(enc)) print(text, norma_enc(guessed_encoding)) assert (text, norma_enc(guessed_encoding)) == (t, norma_enc(enc)) - html = u"""""" % enc + html = """""" % enc text, guessed_encoding = decode_text(html.encode('utf-8'), is_html=True) print(text, norma_enc(guessed_encoding)) assert (text, norma_enc(guessed_encoding)) == (html, norma_enc(enc)) diff --git a/emails/testsuite/loader/test_loaders.py b/emails/testsuite/loader/test_loaders.py index 958574a..6617721 100644 --- a/emails/testsuite/loader/test_loaders.py +++ b/emails/testsuite/loader/test_loaders.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import os from lxml.etree import XMLSyntaxError import pytest diff --git a/emails/testsuite/loader/test_rfc822_loader.py b/emails/testsuite/loader/test_rfc822_loader.py index 5f5cb8b..988db09 100644 --- a/emails/testsuite/loader/test_rfc822_loader.py +++ b/emails/testsuite/loader/test_rfc822_loader.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import glob import email import datetime @@ -41,8 +40,8 @@ def test_msgloader(): data = {'charset': 'utf-8', 'subject': 'Что-то по-русски', - 'mail_from': ('Максим Иванов', 'ivanov@ya.ru'), - 'mail_to': [('Полина Сергеева', 'polina@mail.ru'), ('test', 'test@example.com')], + 'mail_from': ('Максим Иванов', 'ivanov@ya.r'), + 'mail_to': [('Полина Сергеева', 'polina@mail.r'), ('test', 'test@example.com')], 'cc': [('CC User', 'cc@example.com'), ('cc', 'cc.1@example.com')], 'html': '
В первых строках...', 'text': 'Привет!\nВ первых строках...', diff --git a/emails/testsuite/message/__init__.py b/emails/testsuite/message/__init__.py index bca5f67..e69de29 100644 --- a/emails/testsuite/message/__init__.py +++ b/emails/testsuite/message/__init__.py @@ -1 +0,0 @@ -# encoding: utf-8 diff --git a/emails/testsuite/message/helpers.py b/emails/testsuite/message/helpers.py index 79b77b8..b942172 100644 --- a/emails/testsuite/message/helpers.py +++ b/emails/testsuite/message/helpers.py @@ -1,10 +1,9 @@ -# coding: utf-8 import os import emails from emails.template import JinjaTemplate -TO_EMAIL = os.environ.get('SMTP_TEST_MAIL_TO') or 'python.emails.test.2@yandex.ru' +TO_EMAIL = os.environ.get('SMTP_TEST_MAIL_TO') or 'python.emails.test.2@yandex.r' FROM_EMAIL = os.environ.get('SMTP_TEST_MAIL_FROM') or 'python-emails@lavr.me' ROOT = os.path.dirname(__file__) diff --git a/emails/testsuite/message/test_dkim.py b/emails/testsuite/message/test_dkim.py index c3ea16f..e0b796f 100644 --- a/emails/testsuite/message/test_dkim.py +++ b/emails/testsuite/message/test_dkim.py @@ -1,4 +1,3 @@ -# coding: utf-8 import os import email import pytest diff --git a/emails/testsuite/message/test_lazy_gettext.py b/emails/testsuite/message/test_lazy_gettext.py index 0a77ebe..ac75afb 100644 --- a/emails/testsuite/message/test_lazy_gettext.py +++ b/emails/testsuite/message/test_lazy_gettext.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import gettext from emails import Message from emails.utils import decode_header diff --git a/emails/testsuite/message/test_message.py b/emails/testsuite/message/test_message.py index 7f7f830..8a50fd7 100644 --- a/emails/testsuite/message/test_message.py +++ b/emails/testsuite/message/test_message.py @@ -1,4 +1,3 @@ -# coding: utf-8 import datetime from email.utils import parseaddr from dateutil.parser import parse as dateutil_parse diff --git a/emails/testsuite/message/test_send.py b/emails/testsuite/message/test_send.py index 6b70560..a7f00ee 100644 --- a/emails/testsuite/message/test_send.py +++ b/emails/testsuite/message/test_send.py @@ -1,4 +1,3 @@ -# coding: utf-8 import time import random import pytest @@ -18,7 +17,7 @@ def get_letters(): yield emails.html(**data), None # Email with render - yield emails.html(**common_email_data(subject='Render with name=John')), {'name': u'John'} + yield emails.html(**common_email_data(subject='Render with name=John')), {'name': 'John'} # Email with several inline images url = 'http://lavr.github.io/python-emails/tests/campaignmonitor-samples/sample-template/template-widgets.html' diff --git a/emails/testsuite/other/test_requests_encoding_detection.py b/emails/testsuite/other/test_requests_encoding_detection.py deleted file mode 100644 index c384fd7..0000000 --- a/emails/testsuite/other/test_requests_encoding_detection.py +++ /dev/null @@ -1,29 +0,0 @@ -# encoding: utf-8 -import pytest -import requests - -@pytest.mark.xfail -def test_encoding_detection(): - - """ - Broken encoding detection in requests 1.2.3. - I'm failed to explain this bug importance to requests's team: - https://github.com/kennethreitz/requests/issues/1604 - """ - - url = 'http://lavr.github.io/python-emails/tests/requests/some-utf8-text.html' - expected_content = u'我需要单间。' # Chinese is for example only. Any other non-european encodings broken too. - - r = requests.get(url) - - # Response.apparent_encoding is good - assert r.apparent_encoding == 'utf-8' - real_text = unicode(r.content, r.apparent_encoding) - assert expected_content in real_text - - # but Response.text is broken - # (the reason is: commit a0ae2e6) - assert expected_content in r.text - -if __name__=="__main__": - test_encoding_detection() diff --git a/emails/testsuite/smtp/test_factory.py b/emails/testsuite/smtp/test_factory.py index 0c3fd52..2b4692d 100644 --- a/emails/testsuite/smtp/test_factory.py +++ b/emails/testsuite/smtp/test_factory.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import pytest from emails.backend.factory import ObjectFactory diff --git a/emails/testsuite/smtp/test_smtp_backend.py b/emails/testsuite/smtp/test_smtp_backend.py index 0331cc0..c258642 100644 --- a/emails/testsuite/smtp/test_smtp_backend.py +++ b/emails/testsuite/smtp/test_smtp_backend.py @@ -1,4 +1,3 @@ -# encoding: utf-8 import socket @@ -11,7 +10,7 @@ SAMPLE_MESSAGE = {'html': '
Test from python-emails',
'text': 'Test from python-emails',
'mail_from': 's@lavr.me',
- 'mail_to': 'sergei-nko@yandex.ru'}
+ 'mail_to': 'sergei-nko@yandex.r'}
def test_send_to_unknown_host():
diff --git a/emails/testsuite/smtp/test_smtp_response.py b/emails/testsuite/smtp/test_smtp_response.py
index 47ddab3..8834836 100644
--- a/emails/testsuite/smtp/test_smtp_response.py
+++ b/emails/testsuite/smtp/test_smtp_response.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
from emails.backend.response import SMTPResponse
diff --git a/emails/testsuite/smtp_servers.py b/emails/testsuite/smtp_servers.py
index 56c09d4..20201ba 100644
--- a/emails/testsuite/smtp_servers.py
+++ b/emails/testsuite/smtp_servers.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
import os
import platform
import datetime
@@ -100,7 +99,7 @@ def patch_message(self, message):
return message
def __str__(self):
- return u'SMTPTestParams({user}@{host}:{port})'.format(host=self.params.get('host'),
+ return 'SMTPTestParams({user}@{host}:{port})'.format(host=self.params.get('host'),
port=self.params.get('port'),
user=self.params.get('user', ''))
diff --git a/emails/testsuite/store/test_store.py b/emails/testsuite/store/test_store.py
index 462f113..c5596f2 100644
--- a/emails/testsuite/store/test_store.py
+++ b/emails/testsuite/store/test_store.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
from io import BytesIO
import pytest
diff --git a/emails/testsuite/test_templates.py b/emails/testsuite/test_templates.py
index dab2fb6..1dbb5ce 100644
--- a/emails/testsuite/test_templates.py
+++ b/emails/testsuite/test_templates.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
import pytest
from emails.template import MakoTemplate, StringTemplate, JinjaTemplate
from emails.template.base import BaseTemplate
diff --git a/emails/testsuite/test_utils.py b/emails/testsuite/test_utils.py
index c61611a..8b5371d 100644
--- a/emails/testsuite/test_utils.py
+++ b/emails/testsuite/test_utils.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
import pytest
import datetime
import time
diff --git a/emails/testsuite/transformer/test_parser.py b/emails/testsuite/transformer/test_parser.py
index 927bfb3..4a954ce 100644
--- a/emails/testsuite/transformer/test_parser.py
+++ b/emails/testsuite/transformer/test_parser.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
from emails.transformer import HTMLParser
diff --git a/emails/testsuite/transformer/test_transformer.py b/emails/testsuite/transformer/test_transformer.py
index e70883e..5e82202 100644
--- a/emails/testsuite/transformer/test_transformer.py
+++ b/emails/testsuite/transformer/test_transformer.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
import os.path
import emails.loader
from emails.loader.local_store import FileSystemLoader, BaseLoader
diff --git a/emails/transformer.py b/emails/transformer.py
index f586be6..58918f6 100644
--- a/emails/transformer.py
+++ b/emails/transformer.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
import functools
import logging
diff --git a/emails/utils.py b/emails/utils.py
index 78f5a3b..12e03a1 100644
--- a/emails/utils.py
+++ b/emails/utils.py
@@ -1,4 +1,3 @@
-# encoding: utf-8
from __future__ import annotations
import sys
@@ -207,7 +206,7 @@ def parse_name_and_email_list(elements: str | tuple[str | None, str] | list[Any]
def parse_name_and_email(obj: str | tuple[str | None, str] | list[str],
encoding: str = 'utf-8') -> AddressPair:
# In: 'john@smith.me' or '"John Smith"