Skip to content

Conversation

nemacysts
Copy link
Contributor

@nemacysts nemacysts commented Dec 4, 2024

This parameter has been inconsistently typed as either list[str] or tuple[str] - as either is acceptable, we can widen the type to Sequence[str] to satisfy mypy and/or other type checkers.

This will allow for constructs like:

application.run_polling(
    allowed_updates=(
        UpdateType.MESSAGE,
        UpdateType.EDITED_MESSAGE,
    )
)

which currently fails mypy (and likely other typecheckers) with an error like:
error: Argument "allowed_updates" to "run_polling" of "Application" hasincompatible type "tuple[UpdateType, UpdateType]"; expected "list[str] | None" [arg-type]

  • run pre-commit
  • run tests
  • add self to AUTHORS.rst
  • add versionchanged to existing docstrings

This parameter has been inconsistently typed as either list[str] or
tuple[str] - as either is acceptable, we can widen the type to
Sequence[str] to satisfy `mypy` and/or other type checkers.

This will allow for constructs like:
```Python
application.run_polling(
    allowed_updates=(
        UpdateType.MESSAGE,
        UpdateType.EDITED_MESSAGE,
    )
)
```
which currently fails mypy (and likely other typecheckers) with an error
like:
`error: Argument "allowed_updates" to "run_polling" of "Application" hasincompatible type "tuple[UpdateType, UpdateType]"; expected "list[str] | None"  [arg-type]`
@nemacysts
Copy link
Contributor Author

looks like Unit Tests / pytest (3.10, ubuntu-latest) is failing to report coverage with error - 2024-12-04 05:33:48,773 -- Report creating failed: {"message":"Token required because branch is protected"} - however, the actual test stage seems to have passed all tests :)

Copy link
Member

@harshil21 harshil21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@Bibo-Joshi Bibo-Joshi added ⚙️ type-hinting affected functionality: type-hinting 🔌 enhancement pr description: enhancement labels Dec 4, 2024
@Bibo-Joshi Bibo-Joshi merged commit eda2172 into python-telegram-bot:master Dec 4, 2024
21 of 22 checks passed
@Bibo-Joshi
Copy link
Member

Thank you for the contribution!

cuevasrja pushed a commit to USB-CI3715/python-telegram-bot that referenced this pull request Dec 9, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔌 enhancement pr description: enhancement ⚙️ type-hinting affected functionality: type-hinting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants