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

Improve pylint compatibility - sbol3.provelance #459

Merged
merged 4 commits into from
Feb 27, 2025

Conversation

GeneCodeSavvy
Copy link
Contributor

Hello,

PR for #433

After analyzing the pylint reports and wanted to share my observations:

  1. Wildcard Imports Inflate Warning Counts:
    The ~9,000 unused-import warnings appear to stem from a pattern where from . import * statements pull in unused modules/classes. For example, in provenance.py (line 6), a single wildcard import triggers 247 unused-import warnings, each for an unused item. This suggests that many warnings are redundant and could be resolved by replacing wildcard imports with explicit imports of only necessary classes/functions.

  2. Why provenance.py?:

    • It contributes 5.75% of all pylint errors (e.g., class redefinitions, missing docstrings).
    • Its wildcard imports alone generate ~10% of the file’s warnings.

This PR:

  1. Not Yet Complete
  2. It eliminates wildcard-import and unused-import.
  3. Added some scratch changes in .gitignore and setup.cfg for my convenience. That will be removed after the final changes.

Further changes:

  1. provelance.py has functions with access to protected methods like in this case.
def build_usage(identity: str, *, type_uri: str = PROV_USAGE) -> SBOLObject:
    obj = Usage(entity=PYSBOL3_MISSING, identity=identity, type_uri=type_uri)
    # Remove the placeholder values
    obj._properties[PROV_ENTITY] = []
    return obj
  1. too-many-arguments is also common refactor recommendation. Like in the case below.
class Usage(CustomIdentified):
    def __init__(self, entity: str,
                 *, roles: Optional[str, list[str]] = None,
                 name: str = None, description: str = None,
                 derived_from: List[str] = None,
                 generated_by: List[str] = None,
                 measures: List[SBOLObject] = None,
                 identity: str = None,
                 type_uri: str = PROV_USAGE) -> None:
        super().__init__(identity=identity, type_uri=type_uri,
                         name=name, description=description,
                         derived_from=derived_from, generated_by=generated_by,
                         measures=measures)
        self.entity: uri_singleton = URIProperty(self, PROV_ENTITY, 1, 1,
                                                 initial_value=entity)
        self.roles: uri_list = URIProperty(self, PROV_ROLES, 0, math.inf,
                                           initial_value=roles)

Please help with these cases.

Thank you for your guidance!
— Harsh

pylint sbol3/provelance.py
Previous score : 0 / 10
Current score : 8.35 / 10

Copy link
Collaborator

@tcmitchell tcmitchell left a comment

Choose a reason for hiding this comment

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

The builds are failing. This PR cannot be merged until the builds are passing. Please let us know if you need help fixing the builds.

@GeneCodeSavvy
Copy link
Contributor Author

@tcmitchell done, I had removed the pylint config without realising it would interfere with CI / CD

@tcmitchell
Copy link
Collaborator

For both too-many-arguments and protected-access, just leave those checks disabled for now. Those are not the low-hanging fruit. There are something like 45 pylint warnings. My suggestion on the issue was to start with the easy ones and work towards the harder ones. If you need advice on them, they probably don't qualify as "easy".

@GeneCodeSavvy
Copy link
Contributor Author

Okay, then this PR will be merged?

@tcmitchell tcmitchell self-requested a review February 27, 2025 21:04
@tcmitchell tcmitchell merged commit f41bf40 into SynBioDex:main Feb 27, 2025
12 checks passed
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