You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
I am using Pylance and while the Pycrate code works, some parts after encoding/decoding are grayed out as unreachable.
The easiest solution is replacing 'ASN1NotSuppErr' with 'NotImplementedError' in 'pycrate_asn1rt/asnobj.py'.
Other options are given at microsoft/pylance-release#2092 (comment)
It would be a nice improvement for those who use static type analyzers.
Thanks for the report. I don't know Pylance, but apparently, they have some strong assumptions on the Python code it's working on (at least stronger than the Python2 or 3 runtine, and stronger than pypy).
I am basically not in favour of doing code modification just to comply with some or other frameworks. Moreover, I do not use vscode, neither this Pylance extension. Eventually, if you propose a short / tiny patch to pycrate for your case to work, I may integrate it in master (and replacing a custom pycrate exception by a defaut Python one is not something nice, as any code that catches on custom pycrate exception will fail after this modification).
Thanks for the quick reply. It seems other solutions, adding a return type or using abstract classes, cannot be applied because of Python2 support. Type hints require Python 3.5+, whereas abstract class signatures are different for Python 2 and Python 3. Moreover, I can see many instantiations of ASN1Obj, which is impossible for abstract classes. Probably, we will need to wait for Pycrate to abandon Python 2 support, then add type hints directly in the source code. Or separate stub files can be added which are ignored by Python2 as far as I know.
For my local development, I created a stub file 'pycrate_asn1rt/asnobj.pyi' with the following contents:
I am using Pylance and while the Pycrate code works, some parts after encoding/decoding are grayed out as unreachable.
The easiest solution is replacing 'ASN1NotSuppErr' with 'NotImplementedError' in 'pycrate_asn1rt/asnobj.py'.
Other options are given at microsoft/pylance-release#2092 (comment)
It would be a nice improvement for those who use static type analyzers.
Pycrate version: 0.5.5
Pylance version: v2022.11.30
Example to reproduce the issue.
The text was updated successfully, but these errors were encountered: