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

precommit: enable codespell #169

Merged
merged 3 commits into from
Sep 30, 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
4 changes: 2 additions & 2 deletions .github/actions/pkg-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
- name: Install package (wheel)
working-directory: pypi/
run: |
# TODO: reset env / conside add as conda
# TODO: reset env / consider add as conda
pip install *.whl ${{ inputs.pip-flags }}
python -c "import ${{ inputs.import-name }} as pkg; print(f'version: {pkg.__version__}')"
pip list
Expand All @@ -46,7 +46,7 @@ runs:
- name: Install package (archive)
working-directory: pypi/
run: |
# TODO: reset env / conside add as conda
# TODO: reset env / consider add as conda
pip install *.tar.gz ${{ inputs.pip-flags }}
python -c "import ${{ inputs.import-name }} as pkg; print(f'version: {pkg.__version__}')"
pip list
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/find-unused-caches.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Requirements for running equally named scrit,
# Requirements for running equally named script,
# having it in extra file to prevent version discrepancy if hardcoded in workflow

fire
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-code.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check formating flow
name: Check formatting flow

on:
workflow_call:
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ repos:
args: [--py37-plus]
name: Upgrade code

- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies: [tomli]
#args: ["--write-changes"] # uncomment if you want to get automatic fixing

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- CI: Checking schem in both yaml & yml + verbose ([#84](https://github.com/Lightning-AI/utilities/pull/84))
- CI: Checking scheme in both yaml & yml + verbose ([#84](https://github.com/Lightning-AI/utilities/pull/84))


## [0.5.0] - 2022-12-21
Expand Down
25 changes: 12 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ norecursedirs = [
"build",
"docs",
]

addopts = [
"--strict-markers",
"--doctest-modules",
Expand All @@ -39,28 +38,28 @@ exclude_lines = [
"pragma: no cover",
"pass",
]

[tool.coverage.run]
parallel = true
concurrency = "thread"
relative_files = true


[tool.codespell]
# Todo: enable also python files in a next step
skip = '*.py'
quiet-level = 3
# comma separated list of words; waiting for:
# https://github.com/codespell-project/codespell/issues/2839#issuecomment-1731601603
# also adding links until they ignored by its: nature
# https://github.com/codespell-project/codespell/issues/2243#issuecomment-1732019960
ignore-words-list = "te, compiletime"


[tool.black]
# https://github.com/psf/black
line-length = 120
exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)"

[tool.isort]
known_first_party = [
"lightning_utilities",
"tests"
]
skip_glob = []
profile = "black"
line_length = 120
order_by_type = false
multi_line_output = 3
include_trailing_comma = true

[tool.mypy]
files = [
Expand Down
4 changes: 2 additions & 2 deletions src/lightning_utilities/cli/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def _prune_packages(req_file: str, packages: Sequence[str]) -> None:


def _replace_min(fname: str) -> None:
with open(fname) as fo:
req = fo.read().replace(">=", "==")
with open(fname) as fopen:
req = fopen.read().replace(">=", "==")
with open(fname, "w") as fw:
fw.write(req)

Expand Down
2 changes: 1 addition & 1 deletion src/lightning_utilities/core/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def requires(*module_path_version: str, raise_exception: bool = True) -> Callabl
"""Wrap early import failure with some nice exception message.

Args:
module_path_version: pythin package path (e.g. `torch.cuda`) or pip like requiremsnt (e.g. `torch>=2.0.0`)
module_path_version: python package path (e.g. `torch.cuda`) or pip like requiremsnt (e.g. `torch>=2.0.0`)
raise_exception: how strict the check shall be if exit the code or just warn user

Example:
Expand Down
12 changes: 6 additions & 6 deletions src/lightning_utilities/docs/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def _download_file(file_url: str, folder: str) -> str:


def _search_all_occurrences(list_files: List[str], pattern: str) -> List[str]:
"""Search for all occurrences of specific patter in a collection of files.
"""Search for all occurrences of specific pattern in a collection of files.

Args:
list_files: list of files to be scanned
pattern: pattern for search, reg. expression
"""
collected = []
for file_path in list_files:
with open(file_path, encoding="UTF-8") as fo:
body = fo.read()
with open(file_path, encoding="UTF-8") as fopem:
body = fopem.read()
found = re.findall(pattern, body)
collected += found
return collected
Expand All @@ -53,8 +53,8 @@ def _replace_remote_with_local(
relt_path = os.path.dirname(file_path).replace(docs_folder, "")
# filter the path starting with / as not empty folder names
depth = len([p for p in relt_path.split(os.path.sep) if p])
with open(file_path, encoding="UTF-8") as fo:
body = fo.read()
with open(file_path, encoding="UTF-8") as fopen:
body = fopen.read()
for url, fpath in pairs_url_path:
if depth:
path_up = [".."] * depth
Expand All @@ -76,7 +76,7 @@ def fetch_external_assets(
docs_folder: the location of docs related to the project root
assets_folder: a folder inside ``docs_folder`` to be created and saving online assets
file_pattern: what kind of files shall be scanned
retrieve_pattern: patter for reg. expression to search URL/S3 resources
retrieve_pattern: pattern for reg. expression to search URL/S3 resources
"""
list_files = glob.glob(os.path.join(docs_folder, "**", file_pattern), recursive=True)
if not list_files:
Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/docs/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def test_retriever_s3():

fetch_external_assets(docs_folder=path_docs)

with open(path_index, encoding="UTF-8") as fo:
body = fo.read()
with open(path_index, encoding="UTF-8") as fopen:
body = fopen.read()
# that the image exists~
assert "Lightning.gif" in body
# but it is not sourced from S3
assert ".s3." not in body

with open(path_page, encoding="UTF-8") as fo:
body = fo.read()
with open(path_page, encoding="UTF-8") as fopen:
body = fopen.read()
# that the image exists~
assert "Lightning.gif" in body
# check the proper depth
Expand Down
Loading