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

Add linting and formatting to linkml-runtime #347

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

sneakers-the-rat
Copy link
Contributor

@sneakers-the-rat sneakers-the-rat commented Oct 28, 2024

Builds on: #345

The non-modular PR is because the changes to update to 3.9 use the linting rules we're implementing here.

This sets us up with

  • The existing rules in linkml
  • UP - pyupgrade with an override for X | Y types until 3.9 gets dropped
  • T100 - no pdb imports or uses (i am guilty of this a lot)

I punted on a handful of rules for the tests module because there are a lot of violations and it's just in tests, those are mostly assigned values that aren't used, which are fine in tests if a little implicit.

Bigass diff, i'm aware, but that's why we add the linter rules, so future diffs are smaller :)

Review spots

To help out review, all the changes here are linter fixes with no functional change except:

  • linkml_runtime.utils.metamodelcore - There were a handful of invalid error handling blocks that looked like this:

    try:
        # something
    except TypeError:
        pass
    except ValueError:
        pass
    if not is_strict():
        return str(value)
    raise e

    And that isn't valid because e is undefined. It's also ambiguous whether or not those values should always pass, and we raise on any other error, or whether we raise those errors if in strict mode. I assumed the latter, so i changed that to

    try:
        # something
    except (TypeError, ValueError):
        if is_strict():
            raise
    
    return str(value)
  • linkml_runtime.loaders.rdf_loader - there's a reference to pyld_jsonld_from_rdflib_graph and i'm not sure what that is, can't find it anywhere. so i marked it noqa

  • linkml_runtime.utils.permissiblevalueimpl:PvFormulaOptions has a default value that uses EnumDefinition. That would make a pretty nasty dependency loop if we fixed it, so i just commented it out. This prevented the module from being imported at all, so i suspect this is deprecated.

  • tests.__init__.py used an eval call to get a log level, using eval that should basically never be done, so i switched it to getattr

@sneakers-the-rat
Copy link
Contributor Author

looks like we need to add a parameter to the upstream tests that lets us specify which branch to test against.

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.

2 participants