Skip to content

Commit 1e7f26b

Browse files
authored
HDXDSYS-1785 Output errors last from error handler in HDX Python Utilities (#37)
* Output warnings first * styling
1 parent e299464 commit 1e7f26b

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.config/pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
exclude: (test_csv_processing_blanks.csv|test.txt)
1111
- id: check-ast
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.8.6
13+
rev: v0.9.6
1414
hooks:
1515
# Run the linter.
1616
- id: ruff
@@ -19,7 +19,7 @@ repos:
1919
- id: ruff-format
2020
args: [--config, .config/ruff.toml]
2121
- repo: https://github.com/astral-sh/uv-pre-commit
22-
rev: 0.5.15
22+
rev: 0.6.1
2323
hooks:
2424
# Run the pip compile
2525
- id: pip-compile

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ run = """
107107
"""
108108

109109
[tool.hatch.envs.hatch-static-analysis]
110-
dependencies = ["ruff==0.8.6"]
110+
dependencies = ["ruff==0.9.6"]
111111

112112
[tool.hatch.envs.hatch-static-analysis.scripts]
113113
format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]

requirements.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ attrs==25.1.0
88
# jsonlines
99
# jsonschema
1010
# referencing
11-
beautifulsoup4==4.12.3
11+
beautifulsoup4==4.13.3
1212
# via hdx-python-utilities (pyproject.toml)
13-
certifi==2024.12.14
13+
certifi==2025.1.31
1414
# via requests
1515
cfgv==3.4.0
1616
# via pre-commit
@@ -20,7 +20,7 @@ charset-normalizer==3.4.1
2020
# via requests
2121
click==8.1.8
2222
# via typer
23-
coverage==7.6.10
23+
coverage==7.6.12
2424
# via pytest-cov
2525
distlib==0.3.9
2626
# via virtualenv
@@ -36,9 +36,9 @@ frictionless==5.18.0
3636
# via hdx-python-utilities (pyproject.toml)
3737
html5lib==1.1
3838
# via hdx-python-utilities (pyproject.toml)
39-
humanize==4.11.0
39+
humanize==4.12.1
4040
# via frictionless
41-
identify==2.6.6
41+
identify==2.6.7
4242
# via pre-commit
4343
idna==3.10
4444
# via
@@ -159,6 +159,7 @@ typer==0.15.1
159159
# via frictionless
160160
typing-extensions==4.12.2
161161
# via
162+
# beautifulsoup4
162163
# frictionless
163164
# pydantic
164165
# pydantic-core
@@ -170,15 +171,15 @@ urllib3==2.3.0
170171
# via requests
171172
validators==0.34.0
172173
# via frictionless
173-
virtualenv==20.29.1
174+
virtualenv==20.29.2
174175
# via pre-commit
175176
webencodings==0.5.1
176177
# via html5lib
177178
xlrd==2.0.1
178179
# via hdx-python-utilities (pyproject.toml)
179180
xlsx2csv==0.8.4
180181
# via hdx-python-utilities (pyproject.toml)
181-
xlsxwriter==3.2.1
182+
xlsxwriter==3.2.2
182183
# via tableschema-to-template
183184
xlwt==1.3.0
184185
# via hdx-python-utilities (pyproject.toml)

src/hdx/utilities/error_handler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,20 @@ def add_multi_valued(
151151

152152
def log(self) -> None:
153153
"""
154-
Log errors and warnings by category and sorted
154+
Log warnings and errors by category and sorted
155155
156156
Returns:
157157
None
158158
"""
159159

160-
for _, errors in self.shared_errors["error"].items():
161-
errors = sorted(errors)
162-
for error in errors:
163-
logger.error(error)
164160
for _, warnings in self.shared_errors["warning"].items():
165161
warnings = sorted(warnings)
166162
for warning in warnings:
167163
logger.warning(warning)
164+
for _, errors in self.shared_errors["error"].items():
165+
errors = sorted(errors)
166+
for error in errors:
167+
logger.error(error)
168168

169169
def exit_on_error(self) -> None:
170170
"""Exit with a 1 code if there are errors and should_exit_on_error

src/hdx/utilities/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def remove_string(
122122
newstring = remove_end_characters(
123123
newstring, characters_to_remove=end_characters_to_remove
124124
)
125-
return f"{newstring}{string[index + len(toremove):]}"
125+
return f"{newstring}{string[index + len(toremove) :]}"
126126

127127

128128
def get_words_in_sentence(sentence: str) -> List[str]:

0 commit comments

Comments
 (0)