Skip to content

Commit

Permalink
style: 格式化文档
Browse files Browse the repository at this point in the history
  • Loading branch information
qiang1218 committed Jun 29, 2023
1 parent 6ea435a commit dc38df7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/standard/language_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ echo.EchoFilter(input, output, delay=0.7, atten=4)

- [typing](https://google.github.io/styleguide/pyguide.html#typing-imports)
- [collections.abc](https://google.github.io/styleguide/pyguide.html#typing-imports)
- [typing_extensions](https://github.com/python/typing_extensions/blob/main/README.md)
- [typing_extensions](https://github.com/python/typing_extensions/blob/main/README.md)

- 重定向模块 [Six.moves](https://six.readthedocs.io/#module-six.moves)

Expand Down Expand Up @@ -184,7 +184,7 @@ echo.EchoFilter(input, output, delay=0.7, atten=4)

- 如果有必要,请使用内置异常类。例如,抛出 `ValureError`
来指示编程错误。比如违反了前置条件(需要一个正数,但传递了一个负数)。不要使用 `assert` 语句验证公共 API 的参数值。`assert`
用于确保内部正确性,不得强制使用,也不表示发生了某些意外事件。如果在后一种情况下需要使用异常,请使用 raise 语句。例如:
用于确保内部正确性,不得强制使用,也不表示发生了某些意外事件。如果在后一种情况下需要使用异常,请使用 raise 语句。例如:

!!! success "推荐"

Expand Down Expand Up @@ -842,6 +842,7 @@ Python 是一种异常灵活的语言,它为你提供了很多花哨的特性
推荐使用 `from __future__ import` 语句。所有的新代码都应该包含以下内容,现有的代码也应该在有条件的情况下进行兼容更新。

在 3.5 版本(而不是 >= 3.7)上执行的代码中,导入:

```python
from __future__ import generator_stop
```
Expand Down
6 changes: 4 additions & 2 deletions docs/standard/style_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,8 @@ def deals_with_text_data(x: str) -> str:
def deals_with_binary_data(x: bytes) -> bytes:
...
```
如果函数的所有字符串类型始终相同,例如,如果返回类型与上面代码中的参数类型相同,请使用

如果函数的所有字符串类型始终相同,例如,如果返回类型与上面代码中的参数类型相同,请使用
[AnyStr](https://google.github.io/styleguide/pyguide.html#typing-type-var)
想要正确的标注字符串类型,取决于代码将使用哪个版本的 Python 。

Expand All @@ -1459,7 +1460,7 @@ Python 代码中去定义(无论是否有类型)。如果模块中的类型
from typing import Any as AnyType
```

推荐使用内置类型作为注释(如果可用)。 Python 通过 Python 3.9 中引入的 [PEP-585](https://peps.python.org/pep-0585/)
推荐使用内置类型作为注释(如果可用)。 Python 通过 Python 3.9 中引入的 [PEP-585](https://peps.python.org/pep-0585/)
支持使用参数容器类型的类型注释。

```python
Expand All @@ -1468,6 +1469,7 @@ def generate_foo_scores(foo: set[str]) -> list[float]:
```

注意:[Apache Beam](https://github.com/apache/beam/issues/23366) 的用户应继续通过输入导入参数容器。

```python
from typing import Set, List

Expand Down

0 comments on commit dc38df7

Please sign in to comment.