-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix/issue-136-process-robustness #140
Conversation
also refactoring from unittest to pytest
as well as some extra warning about missing variables
and more consistently using pathlib (over os.path)
📝 WalkthroughWalkthroughThe pull request introduces comprehensive changes across the Subyt library, focusing on enhancing type safety, error handling, and testing infrastructure. The modifications span multiple files in the Changes
Suggested labels
Suggested reviewers
Possibly related PRs
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 22
🔭 Outside diff range comments (1)
sema/subyt/sources.py (1)
Line range hint
304-315
: Remove duplicate XML parsing.The XML is parsed twice unnecessarily:
- xml_str = xmlfile.read() - xdict = xmlasdict.parse(xml_str) # unpack root wrappers try: xdict = xmlasdict.parse(xml_str)🧰 Tools
🪛 Ruff (0.8.2)
297-297: Missing return type annotation for special method
__init__
Add return type annotation:
None
(ANN204)
303-303: Missing return type annotation for special method
__enter__
(ANN204)
304-304: Unnecessary open mode parameters
Remove open mode parameters
(UP015)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (11)
sema/subyt/api.py
(6 hunks)sema/subyt/sinks.py
(4 hunks)sema/subyt/sources.py
(11 hunks)sema/subyt/subyt.py
(4 hunks)tests/subyt/test_conditional.py
(1 hunks)tests/subyt/test_generator.py
(4 hunks)tests/subyt/test_j2.py
(2 hunks)tests/subyt/test_processor.py
(1 hunks)tests/subyt/test_repeated_sink_paths.py
(1 hunks)tests/subyt/test_settings.py
(1 hunks)tests/subyt/test_sinks.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
tests/subyt/test_processor.py
109-109: Missing return type annotation for public function test_processor
Add return type annotation: None
(ANN201)
113-113: Unnecessary dict()
call (rewrite as a literal)
Rewrite as a literal
(C408)
tests/subyt/test_conditional.py
22-22: Missing return type annotation for public function test_conditional
Add return type annotation: None
(ANN201)
77-77: Unnecessary dict()
call (rewrite as a literal)
Rewrite as a literal
(C408)
101-101: Trailing comma missing
Add trailing comma
(COM812)
105-105: Logging statement uses f-string
(G004)
115-115: Redundant exception object included in logging.exception
call
(TRY401)
sema/subyt/subyt.py
106-106: Trailing comma missing
Add trailing comma
(COM812)
tests/subyt/test_settings.py
10-10: Missing return type annotation for public function test_statics
Add return type annotation: None
(ANN201)
18-18: Missing return type annotation for public function test_parse
Add return type annotation: None
(ANN201)
26-26: Missing return type annotation for public function test_cases_roundtrip
Add return type annotation: None
(ANN201)
31-31: Unnecessary list()
call (rewrite as a literal)
Rewrite as a literal
(C408)
32-32: Unnecessary list()
call (rewrite as a literal)
Rewrite as a literal
(C408)
35-35: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
tests/subyt/test_repeated_sink_paths.py
13-13: Missing return type annotation for public function test_allow_repeated_sink_paths
Add return type annotation: None
(ANN201)
16-16: Trailing comma missing
Add trailing comma
(COM812)
30-30: Missing return type annotation for public function test_disallow_repeated_sink_paths
Add return type annotation: None
(ANN201)
33-33: Trailing comma missing
Add trailing comma
(COM812)
sema/subyt/api.py
58-58: Missing return type annotation for private function _init_mtimes
Add return type annotation: None
(ANN202)
67-67: Missing return type annotation for private function _init_source
Add return type annotation: None
(ANN202)
112-112: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
113-113: Trailing comma missing
Add trailing comma
(COM812)
146-146: Use of assert
detected
(S101)
165-165: Use key in dict
instead of key in dict.keys()
Remove .keys()
(SIM118)
337-337: Logging statement uses f-string
(G004)
tests/subyt/test_generator.py
12-12: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
16-16: Missing return type annotation for public function load_parts
Add return type annotation: None
(ANN201)
16-16: Missing type annotation for function argument parts
(ANN001)
20-20: Missing return type annotation for private function _assert_count
Add return type annotation: None
(ANN202)
69-69: Unnecessary assignment to indicator
before return
statement
Remove unnecessary assignment
(RET504)
72-72: Missing return type annotation for public function test_templates
Add return type annotation: None
(ANN201)
74-74: Logging statement uses f-string
(G004)
81-81: Unnecessary dict()
call (rewrite as a literal)
Rewrite as a literal
(C408)
87-87: Trailing comma missing
Add trailing comma
(COM812)
107-107: Trailing comma missing
Add trailing comma
(COM812)
111-111: Logging statement uses f-string
(G004)
tests/subyt/test_sinks.py
19-19: Missing return type annotation for public function rand_alfanum_str
(ANN201)
20-20: Standard pseudo-random generators are not suitable for cryptographic purposes
(S311)
24-24: Wrong type passed to first argument of pytest.mark.parametrize
; expected tuple
Use a tuple
for the first argument
(PT006)
32-32: Missing return type annotation for public function test_factory
Add return type annotation: None
(ANN201)
32-32: Missing type annotation for function argument identifier
(ANN001)
32-32: Missing type annotation for function argument expected_type
(ANN001)
50-50: Trailing comma missing
Add trailing comma
(COM812)
53-53: Missing return type annotation for public function test_sink_outputs
Add return type annotation: None
(ANN201)
53-53: Missing type annotation for function argument items
(ANN001)
66-66: Trailing comma missing
Add trailing comma
(COM812)
88-88: Unnecessary open mode parameters
Remove open mode parameters
(UP015)
95-95: Unnecessary open mode parameters
Remove open mode parameters
(UP015)
104-104: Logging statement uses f-string
(G004)
sema/subyt/sinks.py
12-12: Missing return type annotation for public function assert_writable
Add return type annotation: None
(ANN201)
12-12: Boolean-typed positional argument in function definition
(FBT001)
12-12: Boolean default positional argument in function definition
(FBT002)
15-15: Use of assert
detected
(S101)
21-21: Use of assert
detected
(S101)
78-78: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
78-78: Boolean-typed positional argument in function definition
(FBT001)
78-78: Boolean default positional argument in function definition
(FBT002)
85-85: Trailing comma missing
Add trailing comma
(COM812)
88-88: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
90-90: Use explicit conversion flag
Replace with conversion flag
(RUF010)
145-145: Logging statement uses f-string
(G004)
145-145: Trailing comma missing
Add trailing comma
(COM812)
152-153: Logging statement uses f-string
(G004)
153-153: Trailing comma missing
Add trailing comma
(COM812)
177-178: Logging statement uses f-string
(G004)
178-178: Trailing comma missing
Add trailing comma
(COM812)
sema/subyt/sources.py
19-19: Missing return type annotation for public function assert_readable
Add return type annotation: None
(ANN201)
21-21: Use of assert
detected
(S101)
22-22: Use of assert
detected
(S101)
48-48: Use of assert
detected
(S101)
93-93: Unused blanket noqa
directive
Remove unused noqa
directive
(RUF100)
94-94: Use of assert
detected
(S101)
94-94: Assertion always fails, replace with pytest.fail()
(PT015)
94-94: Do not assert False
(python -O
removes these calls), raise AssertionError()
Replace assert False
(B011)
103-103: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
108-108: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
112-112: Use of assert
detected
(S101)
118-118: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
127-127: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
130-130: Missing return type annotation for private function _init_sourcefiles
Add return type annotation: None
(ANN202)
132-132: Use of assert
detected
(S101)
152-152: Trailing comma missing
Add trailing comma
(COM812)
191-191: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
195-195: Trailing comma missing
Add trailing comma
(COM812)
198-198: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
203-203: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
208-208: Trailing comma missing
Add trailing comma
(COM812)
211-211: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
223-223: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
254-254: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
297-297: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: make-lint-test
🔇 Additional comments (7)
tests/subyt/test_j2.py (1)
2-2
: LGTM! Good modernization of path handling.The transition from
os
topathlib.Path
is a good improvement as it provides:
- More robust path handling
- Better cross-platform compatibility
- Type safety through the
Path
objectAlso applies to: 11-13
tests/subyt/test_sinks.py (1)
101-119
: Consider adding test cases for edge cases in pattern leniency.The test verifies basic pattern leniency by setting one key to empty string. Consider adding test cases for:
- Multiple empty keys
- Special characters in keys
- Very long keys
🧰 Tools
🪛 Ruff (0.8.2)
104-104: Logging statement uses f-string
(G004)
sema/subyt/subyt.py (1)
73-77
: LGTM! Well-documented parameter addition.The break_on_error parameter is well documented with clear explanation of its behavior.
sema/subyt/sinks.py (1)
169-179
: LGTM! Enhanced template variable validation.The added validation for missing template variables improves error detection and user feedback.
🧰 Tools
🪛 Ruff (0.8.2)
177-178: Logging statement uses f-string
(G004)
178-178: Trailing comma missing
Add trailing comma
(COM812)
sema/subyt/api.py (3)
58-65
: LGTM! Robust mtime initialization.The implementation correctly handles file validation and mtime initialization with proper type safety.
🧰 Tools
🪛 Ruff (0.8.2)
58-58: Missing return type annotation for private function
_init_mtimes
Add return type annotation:
None
(ANN202)
112-120
: LGTM! Enhanced error handling control.The addition of
break_on_error
parameter improves process robustness by allowing fine-grained control over error handling.🧰 Tools
🪛 Ruff (0.8.2)
112-112: Missing return type annotation for special method
__init__
Add return type annotation:
None
(ANN204)
113-113: Trailing comma missing
Add trailing comma
(COM812)
321-339
: LGTM! Robust error handling implementation.The added try-except block with conditional error propagation based on
break_on_error
setting enhances process robustness.🧰 Tools
🪛 Ruff (0.8.2)
337-337: Logging statement uses f-string
(G004)
Tests coverage table for 006a0f4 commit.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
♻️ Duplicate comments (1)
sema/subyt/sinks.py (1)
85-85
:⚠️ Potential issueFix typo in method name
stats()
The method
stats()
does not exist onPath
objects; it should bestat()
. This typo will cause anAttributeError
at runtime.Apply this diff:
- str(self._file_path): self._file_path.stats().st_mtime + str(self._file_path): self._file_path.stat().st_mtime🧰 Tools
🪛 Ruff (0.8.2)
85-85: Trailing comma missing
Add trailing comma
(COM812)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
sema/subyt/sinks.py
(4 hunks)sema/subyt/sources.py
(11 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
sema/subyt/sinks.py
12-12: Missing return type annotation for public function assert_writable
Add return type annotation: None
(ANN201)
12-12: Boolean-typed positional argument in function definition
(FBT001)
12-12: Boolean default positional argument in function definition
(FBT002)
15-15: Use of assert
detected
(S101)
21-21: Use of assert
detected
(S101)
78-78: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
78-78: Boolean-typed positional argument in function definition
(FBT001)
78-78: Boolean default positional argument in function definition
(FBT002)
85-85: Trailing comma missing
Add trailing comma
(COM812)
88-88: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
90-90: Use explicit conversion flag
Replace with conversion flag
(RUF010)
145-145: Logging statement uses f-string
(G004)
145-145: Trailing comma missing
Add trailing comma
(COM812)
152-153: Logging statement uses f-string
(G004)
153-153: Trailing comma missing
Add trailing comma
(COM812)
177-178: Logging statement uses f-string
(G004)
178-178: Trailing comma missing
Add trailing comma
(COM812)
sema/subyt/sources.py
19-19: Missing return type annotation for public function assert_readable
Add return type annotation: None
(ANN201)
21-21: Use of assert
detected
(S101)
22-22: Use of assert
detected
(S101)
48-48: Use of assert
detected
(S101)
93-93: Unused blanket noqa
directive
Remove unused noqa
directive
(RUF100)
95-95: Trailing comma missing
Add trailing comma
(COM812)
105-105: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
110-110: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
114-114: Use of assert
detected
(S101)
120-120: Unnecessary assignment to source
before return
statement
Remove unnecessary assignment
(RET504)
129-129: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
132-132: Missing return type annotation for private function _init_sourcefiles
Add return type annotation: None
(ANN202)
134-134: Use of assert
detected
(S101)
154-154: Trailing comma missing
Add trailing comma
(COM812)
193-193: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
197-197: Trailing comma missing
Add trailing comma
(COM812)
200-200: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
205-205: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
210-210: Trailing comma missing
Add trailing comma
(COM812)
213-213: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
225-225: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
256-256: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
299-299: Missing return type annotation for special method __init__
Add return type annotation: None
(ANN204)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: make-lint-test
if self._file_path.exists(): | ||
self.mtimes = { | ||
str(self._file_path): self._file_path.stats().st_mtime | ||
} | ||
|
||
def __repr__(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Add return type annotation to __repr__
method
Adding a return type annotation to the __repr__
method enhances code clarity and type checking.
Apply this diff:
- def __repr__(self):
+ def __repr__(self) -> str:
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def __repr__(self): | |
def __repr__(self) -> str: |
🧰 Tools
🪛 Ruff (0.8.2)
88-88: Missing return type annotation for special method __repr__
Add return type annotation: str
(ANN204)
assert not out_path.exists(), ( | ||
f"File to write '{path_name}' already exists", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statements with proper exception handling
Using assert
statements for error checking is not recommended in production code because they can be disabled with optimization flags. It's better to raise explicit exceptions to handle error conditions properly.
Apply this diff to fix the issue:
- assert not out_path.exists(), (
- f"File to write '{path_name}' already exists",
- )
+ if out_path.exists():
+ raise FileExistsError(f"File to write '{path_name}' already exists")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert not out_path.exists(), ( | |
f"File to write '{path_name}' already exists", | |
) | |
if out_path.exists(): | |
raise FileExistsError(f"File to write '{path_name}' already exists") |
🧰 Tools
🪛 Ruff (0.8.2)
15-15: Use of assert
detected
(S101)
assert os.access(parent_path, os.W_OK), ( | ||
f"Can not write to folder '{parent_path}' for creating new files", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statements with proper exception handling
Using assert
statements for checking write permissions is not reliable. Instead, raise an exception to handle the error appropriately.
Apply this diff:
- assert os.access(parent_path, os.W_OK), (
- f"Can not write to folder '{parent_path}' for creating new files",
- )
+ if not os.access(parent_path, os.W_OK):
+ raise PermissionError(f"Cannot write to folder '{parent_path}' for creating new files")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert os.access(parent_path, os.W_OK), ( | |
f"Can not write to folder '{parent_path}' for creating new files", | |
) | |
if not os.access(parent_path, os.W_OK): | |
raise PermissionError(f"Cannot write to folder '{parent_path}' for creating new files") |
🧰 Tools
🪛 Ruff (0.8.2)
21-21: Use of assert
detected
(S101)
out_path: Path = Path(file_path) | ||
if out_path.exists() and out_path.is_dir(): | ||
log.warning( | ||
f"Skipping creation of {file_path} as it is a directory. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Avoid using f-strings in logging statements
Using f-strings in logging methods can lead to unnecessary string interpolation even if the log level is not enabled. It's better to use lazy logging by passing the format string and arguments separately.
Apply this diff:
- f"Skipping creation of {file_path} as it is a directory. "
+ "Skipping creation of %s as it is a directory. File will be ignored.",
+ file_path
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 Ruff (0.8.2)
145-145: Logging statement uses f-string
(G004)
145-145: Trailing comma missing
Add trailing comma
(COM812)
@@ -283,11 +281,11 @@ def __exit__(self): | |||
pass | |||
|
|||
def __repr__(self): | |||
return f"JsonFileSource('{os.path.abspath(self._json)}')" | |||
return f"JsonFileSource('{self._json!s}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Add return type annotation to __repr__
method
Including a return type annotation for __repr__
methods improves type checking and code readability.
Apply this diff:
- def __repr__(self):
+ def __repr__(self) -> str:
Committable suggestion skipped: line range outside the PR's diff.
assert len(self._sourcefiles) > 0, ( | ||
f"{self} should have content files.", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statement with proper exception handling
Using assert
statements for essential runtime checks is not reliable in production code. Raise an exception instead.
Apply this diff:
- assert len(self._sourcefiles) > 0, (
- f"{self} should have content files.",
- )
+ if not self._sourcefiles:
+ raise ValueError(f"{self} should have content files.")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert len(self._sourcefiles) > 0, ( | |
f"{self} should have content files.", | |
) | |
if not self._sourcefiles: | |
raise ValueError(f"{self} should have content files.") |
🧰 Tools
🪛 Ruff (0.8.2)
134-134: Use of assert
detected
(S101)
assert in_path.is_file(), f"File to read '{path_name}' does not exist" | ||
assert os.access(in_path, os.R_OK), f"Can not read '{path_name}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statements with proper exception handling
Using assert
statements for runtime checks is discouraged because they can be disabled with optimization flags. Instead, raise appropriate exceptions to handle error conditions.
Apply this diff:
- assert in_path.is_file(), f"File to read '{path_name}' does not exist"
- assert os.access(in_path, os.R_OK), f"Can not read '{path_name}'"
+ if not in_path.is_file():
+ raise FileNotFoundError(f"File to read '{path_name}' does not exist")
+ if not os.access(in_path, os.R_OK):
+ raise PermissionError(f"Cannot read '{path_name}'")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert in_path.is_file(), f"File to read '{path_name}' does not exist" | |
assert os.access(in_path, os.R_OK), f"Can not read '{path_name}'" | |
if not in_path.is_file(): | |
raise FileNotFoundError(f"File to read '{path_name}' does not exist") | |
if not os.access(in_path, os.R_OK): | |
raise PermissionError(f"Cannot read '{path_name}'") |
🧰 Tools
🪛 Ruff (0.8.2)
21-21: Use of assert
detected
(S101)
22-22: Use of assert
detected
(S101)
assert mime in self._register, ( | ||
f"no Source class available for mime '{mime}'", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statement with proper exception handling
Using assert
statements for control flow is not recommended. Instead, raise an exception if the condition is not met.
Apply this diff:
- assert mime in self._register, (
- f"no Source class available for mime '{mime}'",
- )
+ if mime not in self._register:
+ raise KeyError(f"No Source class available for MIME type '{mime}'")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert mime in self._register, ( | |
f"no Source class available for mime '{mime}'", | |
) | |
if mime not in self._register: | |
raise KeyError(f"No Source class available for MIME type '{mime}'") |
🧰 Tools
🪛 Ruff (0.8.2)
48-48: Use of assert
detected
(S101)
assert mime is not None, ( | ||
f"no valid mime derived from identifier '{identifier}'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace assert
statement with proper exception handling
Using assert
statements for important checks can be risky. Replace with an exception to ensure the check is not bypassed.
Apply this diff:
- assert mime is not None, (
- f"no valid mime derived from identifier '{identifier}'",
- )
+ if mime is None:
+ raise ValueError(f"No valid MIME type derived from identifier '{identifier}'")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
assert mime is not None, ( | |
f"no valid mime derived from identifier '{identifier}'", | |
if mime is None: | |
raise ValueError(f"No valid MIME type derived from identifier '{identifier}'") |
🧰 Tools
🪛 Ruff (0.8.2)
114-114: Use of assert
detected
(S101)
provides fixes for #136 #137 #138
the hope is that these are removing the current block in providing triples inside the emobon workflow...
Summary by CodeRabbit
Release Notes
New Features
break_on_error
option to control error handling during processingImprovements
Path
objects for file path managementpytest
Bug Fixes
Refactoring