diff --git a/aiogram/utils/context.py b/aiogram/utils/context.py
index dfef6882..b31c71c0 100644
--- a/aiogram/utils/context.py
+++ b/aiogram/utils/context.py
@@ -1,5 +1,5 @@
"""
-Need setup task factory:
+You need to setup task factory:
>>> from aiogram.utils import context
>>> loop = asyncio.get_event_loop()
>>> loop.set_task_factory(context.task_factory)
diff --git a/aiogram/utils/executor.py b/aiogram/utils/executor.py
index b1fec35e..ed8947eb 100644
--- a/aiogram/utils/executor.py
+++ b/aiogram/utils/executor.py
@@ -51,7 +51,8 @@ def start_pooling(*args, **kwargs):
return start_polling(*args, **kwargs)
-def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None, on_shutdown=None):
+def start_polling(dispatcher, *, loop=None, skip_updates=False,
+ on_startup=None, on_shutdown=None):
log.warning('Start bot with long-polling.')
if loop is None:
loop = dispatcher.loop
@@ -59,7 +60,7 @@ def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None,
loop.set_task_factory(context.task_factory)
try:
- loop.run_until_complete(_startup(dispatcher, skip_updates=skip_updates, callback=on_startup))
+ loop.run_until_complete(_startup(dispatcher, skip_updates, on_startup))
loop.create_task(dispatcher.start_polling(reset_webhook=True))
loop.run_forever()
except (KeyboardInterrupt, SystemExit):
@@ -69,8 +70,8 @@ def start_polling(dispatcher, *, loop=None, skip_updates=False, on_startup=None,
log.warning("Goodbye!")
-def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None, on_startup=None, on_shutdown=None,
- check_ip=False, **kwargs):
+def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
+ on_startup=None, on_shutdown=None, check_ip=False, **kwargs):
log.warning('Start bot with webhook.')
if loop is None:
loop = dispatcher.loop
diff --git a/aiogram/utils/helper.py b/aiogram/utils/helper.py
index 5b708f18..eeabca7c 100644
--- a/aiogram/utils/helper.py
+++ b/aiogram/utils/helper.py
@@ -137,7 +137,8 @@ class Item:
"""
Helper item
- If value is not configured it will be generated automatically based on variable name
+ If a value is not provided,
+ it will be automatically generated based on a variable's name
"""
def __init__(self, value=None):
@@ -156,7 +157,7 @@ class Item:
class ListItem(Item):
"""
- This item always is list
+ This item is always a list
You can use &, | and + operators for that.
"""
@@ -179,7 +180,7 @@ class ItemsList(list):
"""
Patch for default list
- This class provide +, &, |, +=, &=, |= operators for extending the list
+ This class provides +, &, |, +=, &=, |= operators for extending the list
"""
def __init__(self, *seq):
diff --git a/aiogram/utils/markdown.py b/aiogram/utils/markdown.py
index da08a400..1e64c106 100644
--- a/aiogram/utils/markdown.py
+++ b/aiogram/utils/markdown.py
@@ -18,6 +18,8 @@ HTML_QUOTES_MAP = {
'"': '"'
}
+_HQS = HTML_QUOTES_MAP.keys() # HQS for HTML QUOTES SYMBOLS
+
def _join(*content, sep=' '):
return sep.join(map(str, content))
@@ -38,21 +40,22 @@ def quote_html(content):
"""
Quote HTML symbols
- All <, > and & symbols that are not a part of a tag or an HTML entity
- must be replaced with the corresponding HTML entities (< with <, > with > and & with &).
+ All <, >, & and " symbols that are not a part of a tag or
+ an HTML entity must be replaced with the corresponding HTML entities
+ (< with < > with > & with & and " with ").
:param content: str
:return: str
"""
new_content = ''
for symbol in content:
- new_content += HTML_QUOTES_MAP[symbol] if symbol in '<>&"' else symbol
+ new_content += HTML_QUOTES_MAP[symbol] if symbol in _HQS else symbol
return new_content
def text(*content, sep=' '):
"""
- Join all elements with separator
+ Join all elements with a separator
:param content:
:param sep:
@@ -168,7 +171,7 @@ def hlink(title, url):
:param url:
:return:
"""
- return "{1}".format(url, quote_html(title))
+ return '{1}'.format(url, quote_html(title))
def escape_md(*content, sep=' '):
diff --git a/aiogram/utils/versions.py b/aiogram/utils/versions.py
index f1eb00c3..b621bc62 100644
--- a/aiogram/utils/versions.py
+++ b/aiogram/utils/versions.py
@@ -9,7 +9,8 @@ from .helper import Helper, HelperMode, Item
class Version:
- def __init__(self, major=0, minor=0, maintenance=0, stage='final', build=0):
+ def __init__(self, major=0, minor=0,
+ maintenance=0, stage='final', build=0):
self.__raw_version = None
self.__version = None
@@ -86,7 +87,8 @@ class Version:
if git_changeset:
sub = '.dev{0}'.format(git_changeset)
elif version[3] != Stage.FINAL:
- mapping = {Stage.ALPHA: 'a', Stage.BETA: 'b', Stage.RC: 'rc', Stage.DEV: 'dev'}
+ mapping = {Stage.ALPHA: 'a', Stage.BETA: 'b',
+ Stage.RC: 'rc', Stage.DEV: 'dev'}
sub = mapping[version[3]] + str(version[4])
return str(main + sub)