Skip to content

Commit

Permalink
fix: CI lint complaints
Browse files Browse the repository at this point in the history
I didn't touch any of these Python files in my PR which makes me think
either the linting changed recently or PRs that fail CI have been
getting merged. Anyway, happy to fix them up for the greater good :)
  • Loading branch information
scanny committed Sep 19, 2023
1 parent 48c8330 commit 3769abc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ check: check-src check-tests check-version
## check-src: runs linters (source only, no tests)
.PHONY: check-src
check-src:
ruff . --select I,UP015,UP032,UP034,UP018,COM,C4,PT,SIM,PLR0402 --ignore PT011,PT012,SIM117
ruff . --select I,UP015,UP032,UP034,UP018,COM,C4,PT,SIM,PLR0402 --ignore COM812,PT011,PT012,SIM117
black --line-length 100 ${PACKAGE_NAME} --check
flake8 ${PACKAGE_NAME}
mypy ${PACKAGE_NAME} --ignore-missing-imports --check-untyped-defs
Expand Down
19 changes: 5 additions & 14 deletions scripts/collect_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_os_version():
return platform.platform()


def is_python_package_installed(package_name):
def is_python_package_installed(package_name: str):
"""
Check if a Python package is installed
Expand All @@ -57,14 +57,10 @@ def is_python_package_installed(package_name):
check=True,
)

for line in result.stdout.splitlines():
if line.lower().startswith(package_name.lower()):
return True

return False
return any(line.lower().startswith(package_name.lower()) for line in result.stdout.splitlines())


def is_brew_package_installed(package_name):
def is_brew_package_installed(package_name: str):
"""
Check if a Homebrew package is installed
Expand Down Expand Up @@ -95,11 +91,7 @@ def is_brew_package_installed(package_name):
check=True,
)

for line in result.stdout.splitlines():
if line.lower().startswith(package_name.lower()):
return True

return False
return any(line.lower().startswith(package_name.lower()) for line in result.stdout.splitlines())


def get_python_package_version(package_name):
Expand Down Expand Up @@ -221,8 +213,7 @@ def main():
):
print(
"PaddleOCR version: ",
get_python_package_version("paddlepaddle")
or get_python_package_version("paddleocr"),
get_python_package_version("paddlepaddle") or get_python_package_version("paddleocr"),
)
else:
print("PaddleOCR is not installed")
Expand Down
6 changes: 1 addition & 5 deletions scripts/performance/run_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@

file_path = sys.argv[1]
strategy = sys.argv[2]
model_name = None
if len(sys.argv) > 3:
model_name = sys.argv[3]
else:
model_name = os.environ.get("PARTITION_MODEL_NAME")
model_name = sys.argv[3] if len(sys.argv) > 3 else os.environ.get("PARTITION_MODEL_NAME")
result = partition(file_path, strategy=strategy, model_name=model_name)
# access element in the return value to make sure we got something back, otherwise error
result[1]
7 changes: 2 additions & 5 deletions unstructured/documents/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,8 @@ def _construct_text(tag_elem: etree.Element, include_tail_text: bool = True) ->
return text.strip()


def _has_break_tags(tag_elem: etree.Element) -> bool:
for descendant in tag_elem.iterdescendants():
if descendant.tag in TEXTBREAK_TAGS:
return True
return False
def _has_break_tags(tag_elem: etree._Element) -> bool: # pyright: ignore[reportPrivateUsage]
return any(descendant.tag in TEXTBREAK_TAGS for descendant in tag_elem.iterdescendants())


def _unfurl_break_tags(tag_elem: etree.Element) -> List[etree.Element]:
Expand Down
5 changes: 1 addition & 4 deletions unstructured/partition/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ def partition_json(
last_modification_date = get_last_modified_date_from_file(file)

file_content = file.read()
if isinstance(file_content, str):
file_text = file_content
else:
file_text = file_content.decode()
file_text = file_content if isinstance(file_content, str) else file_content.decode()
file.seek(0)

elif text is not None:
Expand Down
4 changes: 1 addition & 3 deletions unstructured/staging/prodigy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ def _validate_prodigy_metadata(
)
if isinstance(id_error_index, int):
raise ValueError(
'The key "id" is not allowed with metadata parameter at index: {index}'.format(
index=id_error_index,
),
f'The key "id" is not allowed with metadata parameter at index: {id_error_index}'
)
validated_metadata = metadata
else:
Expand Down

0 comments on commit 3769abc

Please sign in to comment.