Skip to content

Commit

Permalink
ci: add dead code detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas1312 committed Oct 10, 2023
1 parent 57b7295 commit a4e53b7
Show file tree
Hide file tree
Showing 20 changed files with 535 additions and 539 deletions.
46 changes: 44 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Pylint test
strategy:
matrix:
python-version: ['3.8', '3.12']
python-version: ["3.8", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['3.8', '3.12']
version: ["3.8", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -151,3 +151,45 @@ jobs:
else
echo "Documentation build completed successfully"
fi
find-dead-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Log dead code
run: >-
{ vulture src/kili tests ; dead ; } |
grep -e "src/kili" |
grep -v
-e "is only referenced in tests"
-e "_ is never read"
-e "internal.py"
-e "unused attribute 'internal'"
-e "affected_rows"
-e "src/kili/orm"
-e "src/kili/types.py"
-e "src/kili/services"
-e "src/kili/entrypoints"
-e "src/kili/core/graphql/ws_graphql_client"
> dead_code.log
- name: Crash if dead code found
run: |
if [ $(cat dead_code.log | wc -l) -gt 0 ]; then
cat dead_code.log
echo "\nDead code found"
exit 1
else
echo "No dead code found"
fi
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ dev = [
"ipykernel",
# profiling
"pyinstrument",
# dead code detection
"vulture==2.10",
"dead==1.5.2",
# other optional dependencies
"opencv-python >= 4.0.0, < 5.0.0",
"azure-storage-blob >= 12.0.0, < 13.0.0",
Expand Down
4 changes: 0 additions & 4 deletions src/kili/adapters/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def patch(self, url: str, **kwargs) -> requests.Response:
"""Send a PATCH request to the given URL."""
return self._send_request("PATCH", url, **kwargs)

def delete(self, url: str, **kwargs) -> requests.Response:
"""Send a DELETE request to the given URL."""
return self._send_request("DELETE", url, **kwargs)

def options(self, url: str, **kwargs) -> requests.Response:
"""Send a OPTIONS request to the given URL."""
return self._send_request("OPTIONS", url, **kwargs)
5 changes: 0 additions & 5 deletions src/kili/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""This script lists package constants."""


NO_ACCESS_RIGHT = (
"[noAccessRights] It seems you do not have access to this object."
" Please double check your credentials."
)

INPUT_TYPE = [
"AUDIO",
"IMAGE",
Expand Down
54 changes: 0 additions & 54 deletions src/kili/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@
"""
from typing import Literal

ExportType = Literal["LATESTNORMAL"]


GraphScale = Literal["DAYMONTHWEEK"]


GraphType = Literal["COUNT_BY_CATEGORIESNUMBER_OF_LABELSHighestRoleInProject"]


HighestRoleInProject = Literal["NAADMINTEAM_MANAGERREVIEWERLABELER"]


HubspotSubscriptionStatus = Literal[
"SUBSCRIBED",
"UNSUBSCRIBED",
]


LabelFormat = Literal[
"RAW",
"SIMPLE",
"YOLO_V4",
"YOLO_V5",
]


LabelType = Literal[
"AUTOSAVE",
"DEFAULT",
Expand Down Expand Up @@ -117,38 +91,10 @@
]


SplitOption = Literal[
"MERGED_FOLDER",
"SPLITTED_FOLDER",
]


Status = Literal[
"TODO",
"ONGOING",
"LABELED",
"REVIEWED",
"TO_REVIEW",
]


UploadType = Literal[
"VIDEO",
"GEO_SATELLITE",
]


WarningTypes = Literal[
"DUPLICATED_ID",
"EMPTY_ARRAY",
"FAILED_ASSET_CREATION",
"FFMPEG_NOT_INSTALLED",
"INPUT_UNDEFINED",
"MAX_INPUT_SIZE",
"MAX_PROJECT_SIZE",
"MISSING_ID",
"NON_INTEGER_FPS",
"UNSUPPORTED_TYPE",
"UNSPECIFIED_ERROR",
"WRONG_CSV_FORMAT",
]
Loading

0 comments on commit a4e53b7

Please sign in to comment.