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

Update ATF importer #552

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open

Update ATF importer #552

wants to merge 47 commits into from

Conversation

khoidt
Copy link
Contributor

@khoidt khoidt commented May 16, 2024

No description provided.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

ebl/atf_importer/application/lemma_lookup.py Outdated Show resolved Hide resolved
ebl/atf_importer/application/lemma_lookup.py Outdated Show resolved Hide resolved
original_atf = atf

try:
if atf.startswith("#lem"):
raise Exception
raise Exception("Special handling for #lem lines.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Raise a specific error instead of the general Exception or BaseException (raise-specific-error)

ExplanationIf a piece of code raises a specific exception type rather than the generic [`BaseException`](https://docs.python.org/3/library/exceptions.html#BaseException) or [`Exception`](https://docs.python.org/3/library/exceptions.html#Exception), the calling code can:
  • get more information about what type of error it is
  • define specific exception handling for it

This way, callers of the code can handle the error appropriately.

How can you solve this?

So instead of having code raising Exception or BaseException like

if incorrect_input(value):
    raise Exception("The input is incorrect")

you can have code raising a specific error like

if incorrect_input(value):
    raise ValueError("The input is incorrect")

or

class IncorrectInputError(Exception):
    pass


if incorrect_input(value):
    raise IncorrectInputError("The input is incorrect")

ebl/atf_importer/application/atf_importer_base.py Outdated Show resolved Hide resolved
ebl/atf_importer/application/atf_importer_base.py Outdated Show resolved Hide resolved
ebl/atf_importer/domain/atf_preprocessor_cdli.py Outdated Show resolved Hide resolved
ebl/atf_importer/domain/atf_preprocessor_cdli.py Outdated Show resolved Hide resolved
ebl/atf_importer/domain/atf_preprocessor_cdli.py Outdated Show resolved Hide resolved
ebl/atf_importer/domain/atf_preprocessor_cdli.py Outdated Show resolved Hide resolved


# Test case for insertion of placeholder if "<<"
def test_placeholder_insert(database):
atf_preprocessor = ATFPreprocessor("../logs", 0)
atf_preprocessor = AtfPreprocessor("../logs", 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): We've found these issues:

khoidt and others added 10 commits May 16, 2024 18:42
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Comment on lines +51 to +53
def _get_valid_museum_number_or_none(
self, museum_number_string: str
) -> Optional[str]:

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
ebl/atf_importer/application/atf_importer.py Fixed Show fixed Hide fixed
ebl/atf_importer/application/atf_importer.py Fixed Show fixed Hide fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant