Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add autocomplete + tests + type checking #1041

Merged
merged 13 commits into from
Sep 12, 2022
29 changes: 17 additions & 12 deletions .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .[dev]
- run: black --check tests src
- run: isort --check-only tests src
- run: flake8 tests src
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install --upgrade pip
pip install .[dev]
- run: black --check tests src
- run: isort --check-only tests src
- run: flake8 tests src
- run: python utils/check_static_imports.py

# Run type checking at least on huggingface_hub root file to check all modules
# that can be lazy-loaded actually exist.
- run: mypy src/huggingface_hub/__init__.py --follow-imports=silent
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
.PHONY: quality style test


check_dirs := tests src setup.py
check_dirs := tests src utils setup.py


quality:
black --check $(check_dirs)
isort --check-only $(check_dirs)
flake8 $(check_dirs)
python utils/check_static_imports.py

style:
black $(check_dirs)
isort $(check_dirs)
python utils/check_static_imports.py --update-file

test:
HUGGINGFACE_CO_STAGING=1 pytest -sv ./tests/
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ def get_version() -> str:
extras["tensorflow"] = ["tensorflow", "pydot", "graphviz"]

extras["testing"] = [
"datasets",
"isort>=5.5.4",
"jedi",
"Jinja2",
"pytest",
"pytest-cov",
"datasets",
"soundfile",
"Jinja2",
]

extras["quality"] = [
"black==22.3",
"isort>=5.5.4",
"flake8>=3.8.3",
"flake8-bugbear",
"isort>=5.5.4",
"mypy",
]

extras["all"] = extras["testing"] + extras["quality"]
Expand Down
Loading