Skip to content

Commit

Permalink
unicode_info: ignore type check on unicodedata2
Browse files Browse the repository at this point in the history
* ignore import error because unicodedata2 doesn't have a stub
* ignore no-redef error because unicodedata2 is optional and
  it has the same interface as unicodedata

Also modified some comments because nitpicking is my pride.

Co-authored-by: dgw <dgw@technobabbl.es>
  • Loading branch information
Exirel and dgw committed Nov 1, 2022
1 parent 2f50dbe commit c728d52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sopel/modules/unicode_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

from sopel import plugin

# unicodedata2 can provide a more-modern UCD than the one that comes with Python, use it if present
# Python built-in unicodedata uses UCD version 13 (as of Python 3.10)
# unicodedata2 can provide a more recent version, so we use that if present
# See also: https://docs.python.org/3/library/unicodedata.html
try:
import unicodedata2 as unicodedata
# ignore type check for these imports (no stubs for unicodedata2)
import unicodedata2 as unicodedata # type: ignore[import]
except ImportError:
import unicodedata
import unicodedata # type: ignore[no-redef]


def get_codepoint_name(char):
Expand Down

0 comments on commit c728d52

Please sign in to comment.