mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-28 20:33:45 +03:00
Create Python tools in favour of shell scripts
Python is likely to be installed when working on Python code, which should make it more portable and consistent.
This commit is contained in:
parent
9c888b83da
commit
e4d88e061d
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,6 +5,7 @@ __pycache__/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
dist/
|
dist/
|
||||||
|
dist-doc/
|
||||||
build/
|
build/
|
||||||
**/tl/__init__.py
|
**/tl/__init__.py
|
||||||
**/tl/layer.py
|
**/tl/layer.py
|
||||||
|
|
|
@ -2,12 +2,19 @@ Code generation:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pip install -e generator/
|
pip install -e generator/
|
||||||
python -m telethon_generator.codegen api.tl client/src/telethon/_impl/tl
|
python tools/codegen.py
|
||||||
python -m telethon_generator.codegen mtproto.tl client/src/telethon/_impl/tl/mtproto
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Formatting, type-checking and testing:
|
Formatting, type-checking and testing:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install isort black mypy pytest pytest-asyncio
|
||||||
|
python tools/check.py
|
||||||
```
|
```
|
||||||
./check.sh
|
|
||||||
|
Documentation:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install sphinx_rtd_theme
|
||||||
|
python tools/docgen.py
|
||||||
```
|
```
|
||||||
|
|
4
check.sh
4
check.sh
|
@ -1,4 +0,0 @@
|
||||||
isort . --profile black --gitignore
|
|
||||||
black . --extend-exclude "tl/(abcs|functions|types)/\w+.py"
|
|
||||||
mypy --strict .
|
|
||||||
pytest . -m "not net"
|
|
22
tools/check.py
Normal file
22
tools/check.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
"""
|
||||||
|
Sort imports, format code, type-check and run offline tests.
|
||||||
|
"""
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def run(*args: str) -> int:
|
||||||
|
return subprocess.run((sys.executable, "-m", *args)).returncode
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
exit(
|
||||||
|
run("isort", ".", "--profile", "black", "--gitignore")
|
||||||
|
or run("black", ".", "--extend-exclude", r"tl/(abcs|functions|types)/\w+.py")
|
||||||
|
or run("mypy", "--strict", ".")
|
||||||
|
or run("pytest", ".", "-m", "not net")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
24
tools/codegen.py
Normal file
24
tools/codegen.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""
|
||||||
|
Run `telethon_generator.codegen` on both `api.tl` and `mtproto.tl` to output
|
||||||
|
corresponding Python code in the default directories under the `client/`.
|
||||||
|
"""
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
GENERATOR = "telethon_generator.codegen"
|
||||||
|
ROOT = "client/src/telethon/_impl"
|
||||||
|
|
||||||
|
|
||||||
|
def run(*args: str) -> int:
|
||||||
|
return subprocess.run((sys.executable, "-m", *args)).returncode
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
exit(
|
||||||
|
run(GENERATOR, "api.tl", f"{ROOT}/tl")
|
||||||
|
or run(GENERATOR, "mtproto.tl", f"{ROOT}/tl/mtproto")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
17
tools/docgen.py
Normal file
17
tools/docgen.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
"""
|
||||||
|
Run `sphinx-build` to create HTML documentation and detect errors.
|
||||||
|
"""
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def run(*args: str) -> int:
|
||||||
|
return subprocess.run((sys.executable, "-m", *args)).returncode
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
exit(run("sphinx", "-nW", "client/doc", "dist-doc"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user