Comments (10)
I am doing this work based on Python 3.8, but even if I add from __future__ Import annotations
, I cannot use the |
flag either
from fastapi_best_architecture.
Because this is not a library, it must pass local code testing, at least >= 3.7 or 3.8
from fastapi_best_architecture.
Hi, @downdawn
Is it convenient for you to perform the test?
I may lose my coding on May 1st because I don't have a laptop and I can only reply to messages via my phone
from fastapi_best_architecture.
Using the | symbol to separate is a feature of python3.10+
https://fastapi.tiangolo.com/python-types/#union
In the local win environment, I use conda to manage the switching environment, and in the Linux environment, I use pyenv. I can test different python versions.
from fastapi_best_architecture.
Yes, but the library based on 3.10 encoding can run in the lower version. I didn’t find the relevant PEP, so I‘m a little confused.
If just replace Optional to Union, it is very convenient, no-optional
from fastapi_best_architecture.
python3.10+ can run directly
def process_item(item: int | str):
print(item, type(item))
if __name__ == '__main__':
process_item(1) # 1 <class 'int'>
process_item("1") # 1 <class 'str'>
python3.7-3.9 can import from __future__ import annotations
run
from fastapi_best_architecture.
After testing, no_optiona can replace Optional[str] = None
with Union[str, None] = None
Can be used in pre-commit.
from fastapi_best_architecture.
python3.10+ can run directly
python3.7-3.9 can import
from __future__ import annotations
run
Yes, This is expected.
There should be some problems in my submission that caused the error.
from fastapi_best_architecture.
After testing, no_optiona can replace
Optional[str] = None
withUnion[str, None] = None
Can be used in pre-commit.
If we use PEP563, this scheme will not be needed. I have updated it to |
through ruff.
from fastapi_best_architecture.
OK
from fastapi_best_architecture.
Related Issues (20)
- Optimize role menu authorization logic
- UUID exception HOT 17
- how to make pytest passed HOT 2
- AccessMiddleware and OperaLogMiddleware cannot exist at the same time. HOT 4
- celery task exception HOT 8
- Argument 'value' has incorrect type (expected str, got UUID) HOT 1
- ✨ TODO HOT 7
- opera_log_middleware exception
- curd/base.py 有个问题 HOT 5
- 📣 Welcome aboard
- 建议新增代码生成功能 HOT 1
- some things HOT 1
- use pydantic EmailStr for email validation HOT 4
- demo 网站出问题了: 内部服务器错误。 HOT 5
- ✨ New backend architecture HOT 1
- Dynamic Configuration: Dynamic configuration of the system environment (site title, logo, filing, footer...)
- Nice project and some personal issue. HOT 2
- 安装过依赖之后,我直接在backend下面执行main.py报错,提示ModuleNotFoundError: No module named 'backend' HOT 2
- ❔ questions database HOT 5
- Celery with asyncio? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi_best_architecture.