mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-27 08:50:38 +01:00
Update pre-commit Settings & Improve a Test (#2796)
This commit is contained in:
parent
28c8c155ce
commit
9b56be44b4
12 changed files with 22 additions and 22 deletions
|
@ -14,12 +14,14 @@ repos:
|
|||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/PyCQA/pylint
|
||||
rev: v2.11.1
|
||||
rev: v2.12.1
|
||||
hooks:
|
||||
- id: pylint
|
||||
files: ^(telegram|examples)/.*\.py$
|
||||
args:
|
||||
- --rcfile=setup.cfg
|
||||
# run pylint across multiple cpu cores to speed it up-
|
||||
- --jobs=0 # See https://pylint.pycqa.org/en/latest/user_guide/run.html?#parallel-execution to know more
|
||||
additional_dependencies:
|
||||
- certifi
|
||||
- tornado>=6.1
|
||||
|
|
|
@ -5,7 +5,7 @@ pre-commit
|
|||
# Make sure that the versions specified here match the pre-commit settings!
|
||||
black==21.9b0
|
||||
flake8==4.0.1
|
||||
pylint==2.11.1
|
||||
pylint==2.12.1
|
||||
mypy==0.910
|
||||
pyupgrade==2.29.0
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class CallbackQuery(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=invalid-name
|
||||
from_user: User,
|
||||
chat_instance: str,
|
||||
message: Message = None,
|
||||
|
|
|
@ -204,7 +204,7 @@ class Chat(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
id: int, # pylint: disable=invalid-name
|
||||
type: str,
|
||||
title: str = None,
|
||||
username: str = None,
|
||||
|
|
|
@ -75,7 +75,7 @@ class InlineQuery(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=redefined-builtin, invalid-name
|
||||
from_user: User,
|
||||
query: str,
|
||||
offset: str,
|
||||
|
|
|
@ -48,7 +48,7 @@ class InlineQueryResult(TelegramObject):
|
|||
|
||||
__slots__ = ('type', 'id')
|
||||
|
||||
def __init__(self, type: str, id: str, **_kwargs: Any):
|
||||
def __init__(self, type: str, id: str, **_kwargs: Any): # pylint: disable=invalid-name
|
||||
# Required
|
||||
self.type = type
|
||||
self.id = str(id) # pylint: disable=invalid-name
|
||||
|
|
|
@ -79,7 +79,7 @@ class PreCheckoutQuery(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=redefined-builtin, invalid-name
|
||||
from_user: User,
|
||||
currency: str,
|
||||
total_amount: int,
|
||||
|
|
|
@ -50,7 +50,7 @@ class ShippingOption(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=redefined-builtin, invalid-name
|
||||
title: str,
|
||||
prices: List['LabeledPrice'],
|
||||
**_kwargs: Any,
|
||||
|
|
|
@ -58,7 +58,7 @@ class ShippingQuery(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=redefined-builtin, invalid-name
|
||||
from_user: User,
|
||||
invoice_payload: str,
|
||||
shipping_address: ShippingAddress,
|
||||
|
|
|
@ -168,7 +168,7 @@ class Poll(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: str, # pylint: disable=redefined-builtin
|
||||
id: str, # pylint: disable=redefined-builtin, invalid-name
|
||||
question: str,
|
||||
options: List[PollOption],
|
||||
total_voter_count: int,
|
||||
|
|
|
@ -110,7 +110,7 @@ class User(TelegramObject):
|
|||
|
||||
def __init__(
|
||||
self,
|
||||
id: int,
|
||||
id: int, # pylint: disable=invalid-name
|
||||
first_name: str,
|
||||
is_bot: bool,
|
||||
last_name: str = None,
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
import datetime
|
||||
import inspect
|
||||
import logging
|
||||
import time
|
||||
import datetime as dtm
|
||||
from collections import defaultdict
|
||||
from platform import python_implementation
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
|
@ -54,7 +54,7 @@ from telegram import (
|
|||
)
|
||||
from telegram.constants import ChatAction, ParseMode, InlineQueryLimit
|
||||
from telegram.ext import ExtBot, InvalidCallbackData
|
||||
from telegram.error import BadRequest, InvalidToken, NetworkError, RetryAfter, TelegramError
|
||||
from telegram.error import BadRequest, InvalidToken, NetworkError, TelegramError
|
||||
from telegram._utils.datetime import from_timestamp, to_timestamp
|
||||
from telegram._utils.defaultvalue import DefaultValue
|
||||
from telegram.helpers import escape_markdown
|
||||
|
@ -470,10 +470,6 @@ class TestBot:
|
|||
assert message.has_protected_content
|
||||
|
||||
@flaky(3, 1)
|
||||
@pytest.mark.xfail(raises=RetryAfter)
|
||||
@pytest.mark.skipif(
|
||||
python_implementation() == 'PyPy', reason='Unstable on pypy for some reason'
|
||||
)
|
||||
def test_send_contact(self, bot, chat_id):
|
||||
phone_number = '+11234567890'
|
||||
first_name = 'Leandro'
|
||||
|
@ -602,7 +598,7 @@ class TestBot:
|
|||
assert new_message.poll.id == message.poll.id
|
||||
assert new_message.poll.is_closed
|
||||
|
||||
@flaky(5, 1)
|
||||
@flaky(3, 1)
|
||||
def test_send_close_date_default_tz(self, tz_bot, super_group_id):
|
||||
question = 'Is this a test?'
|
||||
answers = ['Yes', 'No', 'Maybe']
|
||||
|
@ -613,24 +609,26 @@ class TestBot:
|
|||
aware_close_date = dtm.datetime.now(tz=tz_bot.defaults.tzinfo) + dtm.timedelta(seconds=5)
|
||||
close_date = aware_close_date.replace(tzinfo=None)
|
||||
|
||||
message = tz_bot.send_poll(
|
||||
msg = tz_bot.send_poll( # The timezone returned from this is always converted to UTC
|
||||
chat_id=super_group_id,
|
||||
question=question,
|
||||
options=answers,
|
||||
close_date=close_date,
|
||||
timeout=60,
|
||||
)
|
||||
assert message.poll.close_date == aware_close_date.replace(microsecond=0)
|
||||
# Sometimes there can be a few seconds delay, so don't let the test fail due to that-
|
||||
msg.poll.close_date = msg.poll.close_date.astimezone(aware_close_date.tzinfo)
|
||||
assert abs(msg.poll.close_date - aware_close_date) <= datetime.timedelta(seconds=5)
|
||||
|
||||
time.sleep(5.1)
|
||||
|
||||
new_message = tz_bot.edit_message_reply_markup(
|
||||
chat_id=super_group_id,
|
||||
message_id=message.message_id,
|
||||
message_id=msg.message_id,
|
||||
reply_markup=reply_markup,
|
||||
timeout=60,
|
||||
)
|
||||
assert new_message.poll.id == message.poll.id
|
||||
assert new_message.poll.id == msg.poll.id
|
||||
assert new_message.poll.is_closed
|
||||
|
||||
@flaky(3, 1)
|
||||
|
|
Loading…
Add table
Reference in a new issue