Skip to content
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

[WIP] Add typehint to data.py #7242

Closed
wants to merge 17 commits into from
7 changes: 4 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ jobs:
submodules: 'true'
- uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.8'
architecture: 'x64'
- name: Install Python packages
run: |
python -m pip install wheel setuptools mypy pandas dask[complete] distributed
python -m pip install wheel setuptools mypy pandas dask[complete] distributed types-setuptools
- name: Run mypy
run: |
make mypy
cd python-package
mypy .

doxygen:
runs-on: ubuntu-latest
Expand Down
17 changes: 0 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,6 @@ cover: check
)
endif


# dask is required to pass, others are not
# If any of the dask tests failed, contributor won't see the other error.
mypy:
cd python-package; \
mypy ./xgboost/dask.py && \
mypy ./xgboost/rabit.py && \
mypy ./xgboost/tracker.py && \
mypy ./xgboost/sklearn.py && \
mypy ../demo/guide-python/external_memory.py && \
mypy ../demo/guide-python/categorical.py && \
mypy ../demo/guide-python/cat_in_the_dat.py && \
mypy ../tests/python-gpu/test_gpu_with_dask.py && \
mypy ../tests/python/test_data_iterator.py && \
mypy ../tests/python-gpu/test_gpu_data_iterator.py || exit 1; \
mypy . || true ;

clean:
$(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o #xgboost
$(RM) -rf build_tests *.gcov tests/cpp/xgboost_test
Expand Down
6 changes: 5 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# documentation build configuration file, created by
# sphinx-quickstart on Thu Jul 23 19:40:08 2015.
Expand All @@ -11,6 +10,7 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from __future__ import annotations
from subprocess import call
from sh.contrib import git
import urllib.request
Expand Down Expand Up @@ -98,6 +98,10 @@
}

autodoc_typehints = "description"
autodoc_typehints_format = "short"
autodoc_preserve_defaults = True

autodoc_type_aliases = {"ArrayLike": "xgboost.typing.ArrayLike"}

graphviz_output_format = 'png'
plot_formats = [('svg', 300), ('png', 100), ('hires.png', 300)]
Expand Down
12 changes: 12 additions & 0 deletions doc/python/python_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,15 @@ Dask API
:members:
:inherited-members:
:show-inheritance:

Types
-----
.. automodule:: xgboost.typing

.. autoclass:: xgboost.typing.ArrayLike

.. autoclass:: NativeInput

.. autoclass:: FeatureNames

.. autoclass:: FeatureTypes
5 changes: 2 additions & 3 deletions python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import shutil
import subprocess
import logging
import distutils
from typing import Optional, List
import sys
from platform import system
Expand Down Expand Up @@ -51,11 +50,11 @@ def lib_name() -> str:
def copy_tree(src_dir: str, target_dir: str) -> None:
'''Copy source tree into build directory.'''
def clean_copy_tree(src: str, dst: str) -> None:
distutils.dir_util.copy_tree(src, dst)
shutil.copytree(src, dst)
NEED_CLEAN_TREE.add(os.path.abspath(dst))

def clean_copy_file(src: str, dst: str) -> None:
distutils.file_util.copy_file(src, dst)
shutil.copy(src, dst)
NEED_CLEAN_FILE.add(os.path.abspath(dst))

src = os.path.join(src_dir, 'src')
Expand Down
Loading