Skip to content

Improvements to make.py and pyright configuration #1746

New issue

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

Merged
merged 5 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,9 @@ Be sure to re-run build & refresh to update after making changes!

## Optional: Improve Ergonomics on Mac and Linux

### Enable `./make.py`
### `./make.py` shorthand

On Mac & Linux, you can enable running `make.py` using `./make.py` instead
of `python make.py` as follows:

1. Make sure you are in the root directory of the repo
2. Run `chmod u+x make.py`

You can run the make script with `./make.py` instead of `python make.py`.
On Mac & Linux, you can run the make script as `./make.py` instead of `python make.py`.

For example, this command:
```commandline
Expand All @@ -163,8 +157,7 @@ can now be run this way:

### Enable Shell Completions

After enabling the short-form syntax as outlined above, you can also enable tab
completion for commands on the following supported shells:
On Mac & Linux, you can enable tab completion for commands on the following supported shells:

* `bash` (the most common default shell)
* `zsh`
Expand All @@ -182,6 +175,8 @@ Tab completion would allow you to press tab to auto-complete the command:
./make.py html
```

Note that this may interfere if you work on other projects that also have a `make.py` file.

To enable this feature, most users can follow these steps:

1. Run `./make.py whichshell` to find out what your default shell is
Expand Down
85 changes: 48 additions & 37 deletions make.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def _resolve(p: PathLike, strict: bool = False) -> Path:
RUFFOPTS = ["arcade"]
MYPY = "mypy"
MYPYOPTS = ["arcade"]

PYRIGHT = "pyright"
PYRIGHTOPTS = []

# Testing
PYTEST = "pytest"
Expand Down Expand Up @@ -150,7 +151,7 @@ def run_doc(args: Union[str, List[str]]) -> None:
run(args, cd=FULL_DOC_DIR)


@app.command()
@app.command(rich_help_panel="Docs")
def clean():
"""
Delete built website files.
Expand All @@ -160,7 +161,7 @@ def clean():
os.remove(item) if os.path.isfile(item) else rmtree(item)


@app.command()
@app.command(rich_help_panel="Docs")
def html():
"""
to make standalone HTML files
Expand All @@ -170,15 +171,15 @@ def html():
print(f"Build finished. The HTML pages are in {FULL_BUILD_PREFIX}/html.")


@app.command()
@app.command(rich_help_panel="Docs")
def serve():
"""
Build and serve standalone HTML files, with automatic rebuilds and live reload.
"""
run_doc([SPHINXAUTOBUILD, *SPHINXAUTOBUILDOPTS, '-b', 'html', *ALLSPHINXOPTS, f'{BUILDDIR}/html'])


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def dirhtml():
"""
to make HTML files named index.html in directories
Expand All @@ -188,7 +189,7 @@ def dirhtml():
print(f"Build finished. The HTML pages are in {FULL_BUILD_PREFIX}/dirhtml.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def singlehtml():
"""
to make a single large HTML file
Expand All @@ -198,7 +199,7 @@ def singlehtml():
print(f"Build finished. The HTML page is in {FULL_BUILD_PREFIX}/singlehtml.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def pickle():
"""
to make pickle files
Expand All @@ -208,7 +209,7 @@ def pickle():
print("Build finished; now you can process the pickle files.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def json():
"""
to make JSON files
Expand All @@ -218,7 +219,7 @@ def json():
print("Build finished; now you can process the JSON files.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def htmlhelp():
"""
to make HTML files and a HTML help project
Expand All @@ -229,7 +230,7 @@ def htmlhelp():
f".hhp project file in {FULL_BUILD_PREFIX}/htmlhelp.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def qthelp():
"""
to make HTML files and a qthelp project
Expand All @@ -243,7 +244,7 @@ def qthelp():
print(f"# assistant -collectionFile {FULL_BUILD_PREFIX}/qthelp/Arcade.qhc")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def applehelp():
"""
to make an Apple Help Book
Expand All @@ -256,7 +257,7 @@ def applehelp():
"bundle.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def devhelp():
"""
to make HTML files and a Devhelp project
Expand All @@ -271,7 +272,7 @@ def devhelp():
print("# devhelp")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def epub():
"""
to make an epub
Expand All @@ -281,7 +282,7 @@ def epub():
print(f"Build finished. The epub file is in {FULL_BUILD_PREFIX}/epub.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def latex():
"""
to make LaTeX files, you can set PAPER_SIZE=a4 or PAPER_SIZE=letter
Expand All @@ -293,7 +294,7 @@ def latex():
"(use \`make latexpdf' here to do that automatically).")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def latexpdf():
"""
to make LaTeX files and run them through pdflatex
Expand All @@ -304,7 +305,7 @@ def latexpdf():
print(f"pdflatex finished; the PDF files are in {FULL_BUILD_PREFIX}/latex.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def latexpdfja():
"""
to make LaTeX files and run them through platex/dvipdfmx
Expand All @@ -315,7 +316,7 @@ def latexpdfja():
print(f"pdflatex finished; the PDF files are in {FULL_BUILD_PREFIX}/latex.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def text():
"""
to make text files
Expand All @@ -325,7 +326,7 @@ def text():
print(f"Build finished. The text files are in {FULL_BUILD_PREFIX}/text.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def man():
"""
to make manual pages
Expand All @@ -335,7 +336,7 @@ def man():
print(f"Build finished. The manual pages are in {FULL_BUILD_PREFIX}/man.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def texinfo():
"""
to make Texinfo files
Expand All @@ -347,7 +348,7 @@ def texinfo():
"(use \`make info' here to do that automatically).")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def info():
"""
to make Texinfo files and run them through makeinfo
Expand All @@ -358,7 +359,7 @@ def info():
print(f"makeinfo finished; the Info files are in {FULL_BUILD_PREFIX}/texinfo.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def gettext():
"""
to make PO message catalogs
Expand All @@ -368,7 +369,7 @@ def gettext():
print(f"Build finished. The message catalogs are in {FULL_BUILD_PREFIX}/locale.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def changes():
"""
to make an overview of all changed/added/deprecated items
Expand All @@ -378,7 +379,7 @@ def changes():
print(f"The overview file is in {FULL_BUILD_PREFIX}/changes.")


@app.command()
@app.command(rich_help_panel="Code Quality")
def linkcheck():
"""
to check all external links for integrity
Expand All @@ -389,7 +390,7 @@ def linkcheck():
f"or in {FULL_BUILD_PREFIX}/linkcheck/output.txt.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def doctest():
"""
to run all doctests embedded in the documentation (if enabled)
Expand All @@ -399,7 +400,7 @@ def doctest():
f"results in {FULL_BUILD_PREFIX}/doctest/output.txt.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def coverage():
"""
to run coverage check of the documentation (if enabled)
Expand All @@ -409,48 +410,58 @@ def coverage():
f"results in {FULL_BUILD_PREFIX}/coverage/python.txt.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def xml():
run_doc([SPHINXBUILD, "-b", "xml", *ALLSPHINXOPTS, f"{BUILDDIR}/xml"])
print()
print(f"Build finished. The XML files are in {FULL_BUILD_PREFIX}/xml.")


@app.command()
@app.command(rich_help_panel="Additional Doc Formats")
def pseudoxml():
run_doc([SPHINXBUILD, "-b", "pseudoxml", *ALLSPHINXOPTS, f"{BUILDDIR}/pseudoxml"])
print()
print(f"Build finished. The pseudo-XML files are in {FULL_BUILD_PREFIX}/pseudoxml.")


@app.command()
@app.command(rich_help_panel="Code Quality")
def lint():
run([RUFF, *RUFFOPTS])
print("Ruff Finished.")
run([MYPY, *MYPYOPTS])
print("Mypy Finished.")
"""
Run all linting tasks: ruff and mypy (Run this before making a pull request!)
"""
ruff()
mypy()
print("Linting Complete.")


@app.command()
@app.command(rich_help_panel="Code Quality")
def ruff():
run([RUFF, *RUFFOPTS])
print("Ruff Finished.")


@app.command()
@app.command(rich_help_panel="Code Quality")
def mypy():
"Typecheck using mypy"
run([MYPY, *MYPYOPTS])
print("MyPy Finished.")


@app.command()
@app.command(rich_help_panel="Code Quality")
def pyright():
"Typecheck using pyright"
run([PYRIGHT, *PYRIGHTOPTS])
print("Pyright Finished.")


@app.command(rich_help_panel="Code Quality")
def test_full():
run([PYTEST, TESTDIR])


@app.command()
@app.command(rich_help_panel="Code Quality")
def test():
"""Run unit tests (Run this before making a pull request!)"""
run([PYTEST, UNITTESTS])


Expand All @@ -463,7 +474,7 @@ def test():
)


@app.command()
@app.command(rich_help_panel="Shell Completion")
def whichshell():
"""to find out which shell your system seems to be running"""

Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ dev = [
"pygments==2.14.0",
"docutils==0.19",
"furo",
"pyright",
"pyyaml==6.0",
"sphinx==6.1.3",
"sphinx-autobuild==2021.3.14",
"sphinx-copybutton==0.5.1",
# Intentionally kept at 2.3 until this bugfix is published: https://github.com/jdillard/sphinx-sitemap/pull/62
"sphinx-sitemap==2.3.0",
"typer==0.7.0",
"typer[all]==0.7.0",
"wheel",
]

Expand Down Expand Up @@ -103,6 +104,9 @@ norecursedirs = ["doc", "holding", "arcade/examples", "build", ".venv", "env", "
[tool.pyright]
include = ["arcade"]
exclude = ["venv", "arcade/examples", "arcade/experimental", "tests", "doc"]
# Use type info from pytiled_parser and pyglet, which do not ship `py.typed` file
useLibraryCodeForTypes = true
reportMissingTypeStubs = "none"

[tool.coverage.run]
source = ["arcade"]
Expand Down