Skip to content
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
3 changes: 1 addition & 2 deletions .github/workflows/build-ubuntu-sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ jobs:
- name: Test typestubs
if: matrix.os == 'ubuntu-22.04' # run stubtest only once
run: |
cd buildconfig/stubs
pip3 install mypy
python3 -m mypy.stubtest pygame --allowlist mypy_allow_list.txt
python3 setup.py stubcheck

# We upload the generated files under github actions assets
- name: Upload sdist
Expand Down
32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,38 @@ def run(self):
if subprocess.call(command_line) != 0:
raise SystemExit("Failed to build documentation")

@add_command('stubcheck')
class StubcheckCommand(Command):
""" For checking the stubs with `python setup.py stubcheck`.
"""
user_options = []
def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
'''
runs mypy to build the docs.
'''
import subprocess
import warnings

print("Using python:", sys.executable)

if shutil.which('mypy') is None:
warnings.warn("Please install 'mypy' in your environment. (hint: 'python3 -m pip install mypy')")
sys.exit(1)

os.chdir('buildconfig/stubs')
command_line = [
sys.executable,'-m','mypy.stubtest',"pygame","--allowlist","mypy_allow_list.txt"
]
result = subprocess.run(command_line)
os.chdir('../../')
if result.returncode != 0:
raise SystemExit("Stubcheck failed.")

# Prune empty file lists.
data_files = [(path, files) for path, files in data_files if files]
Expand Down