We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在之前的版本里为了兼容低版本 Python 环境,我移除了类型声明。但这导致了诸多问题,尤其是开发流程的模糊化, IDE 不再具有合理的推导功能。
为了项目更好的发展,我希望重新引入各个类型的声明。
The text was updated successfully, but these errors were encountered:
支持 有个小建议,对于低版本python在运行时由于环境导致的报错TypeError: unsupported operand type(s) for |: 'type' and 'type'可以手动抛出异常,指引用户去降级 比如抛出异常Exception(“python版本过低,可以尝试降级pip install snbtlib==旧版本”)
TypeError: unsupported operand type(s) for |: 'type' and 'type'
Exception(“python版本过低,可以尝试降级pip install snbtlib==旧版本”)
Sorry, something went wrong.
非常好的建议,但可能有点难。原因在于: Python 的解释器在解释到非法语法时,会直接拒绝执行,例如上面的
> TypeError: unsupported operand type(s) for |: 'type' and 'type'
是解释器直接抛出的错误,它并没有执行任何的代码。
这就代表了它可能很难在源码层面给出版本兼容性提示。一个可能的办法是利用 pypi 的包管理机制,当低版本 pip 工具执行安装命令时,限制可安装的包版本范围。
确实,用包管理器能实现也不错,从根源上避免。不论什么方式我觉得能指出不是此库本身的错误就好。
另外有一个很另类的写法,把import放到try中可以再抛出一个自定义的异常 main.py中的内容
if __name__ == '__main__': try: import test except Exception as e: raise Exception('test的代码有误') else: print('正常')
这里test这个库中代码是无法通过编译器的 test.py内容
if __name__ == '__main__': print('1'
No branches or pull requests
在之前的版本里为了兼容低版本 Python 环境,我移除了类型声明。但这导致了诸多问题,尤其是开发流程的模糊化, IDE 不再具有合理的推导功能。
为了项目更好的发展,我希望重新引入各个类型的声明。
The text was updated successfully, but these errors were encountered: