mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-12 17:22:25 +03:00
Fix quirk of enum values in Python
After the Cython 3 change, the types of enum members such as spacy.parts_of_speech.NOUN became 'flag', rather than simple 'int'. This change mostly doesn't matter because the flag type does duck-type like an int -- it compares, additions, prints etc the same. However, it doesn't repr the same and if you do an isinstance check it will fail. It's therefore better to just make them ints like they were before.
This commit is contained in:
parent
4b65aa79ee
commit
5e1ee975c9
|
@ -91,6 +91,9 @@ IDS = {
|
|||
"MORPH": MORPH,
|
||||
"IDX": IDX,
|
||||
}
|
||||
# Make these ints in Python, so that we don't get this unexpected 'flag' type
|
||||
# This will match the behaviour before Cython 3
|
||||
IDS = {name: int(value) for name, value in IDS.items()}
|
||||
|
||||
|
||||
# ATTR IDs, in order of the symbol
|
||||
|
|
|
@ -23,7 +23,9 @@ IDS = {
|
|||
"SPACE": SPACE
|
||||
}
|
||||
|
||||
|
||||
# Make these ints in Python, so that we don't get this unexpected 'flag' type
|
||||
# This will match the behaviour before Cython 3
|
||||
IDS = {name: int(value) for name, value in IDS.items()}
|
||||
NAMES = {value: key for key, value in IDS.items()}
|
||||
|
||||
# As of Cython 3.1, the global Python namespace no longer has the enum
|
||||
|
|
Loading…
Reference in New Issue
Block a user