question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Algorithm metadata causes pyright reportUnusedVariable errors

See original GitHub issue

In each algorithm directory’s __init__.py, there is metadata along the lines of:

_name = 'SqueezeExcite'
_class_name = 'SqueezeExcite'
_functional = 'apply_se'
_tldr = 'Replaces eligible layers with Squeeze-Excite layers'
_attribution = 'Hu et al, 2017'
_link = 'https://arxiv.org/abs/1709.01507'
_method_card = ''

Each of these fields causes pyright to raise a reportUnusedVariable error. This both clutters the pyright output during linting and prevents updating the metadata (without type: ignore annotations) due to our PR gates.

I propose to do one of the following in each algorithm’s __init__.py:

  1. add type: ignore[reportUnusedVariable] to each line,
  2. configure pyright to ignore these __init__.py files entirely, or
  3. Wrap the metadata fields in a MetaData class decorated with @no_type_check (and update composer.tables logic appropriately.

1 and 3 both seem fine to me and I don’t think this matters enough to have a whole design discussion about it. Ideally we’d use some annotation to ignore a particular error for that whole block, but that doesn’t seem to be an option in pyright (or PEP 484).

Alternatively, we could centralize the metadata somewhere else, have yaml files instead, or various other options. Curious what @hanlint thinks since I don’t have great perspective on the downstream usage.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
hanlintcommented, Feb 11, 2022

Discussed offline with @dblalock , and he prefers the json approach. Declutters the python namespace and makes it accessible outside. Will implement a fix here.

1reaction
hanlintcommented, Feb 10, 2022

I like the MetaData class. Embedding directly in the class-level attributes would clutter the namespace with attributes not really used by developers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reportUnusedVariable false positives · Issue #3728 - GitHub
Describe the bug reportUnusedVariables reports used variables (found in variables captured by a match statement).
Read more >
python - Unused parameter only greyed out but not reported
If you're using Pylance or Pyright, seems like you can't mark unused parameters as errors. They're not always errors - sometimes you need ......
Read more >
pyright Changelog - pyup.io
Bug Fix: Fixed bug that leads to a false positive error when using a class whose constructor doesn't contain any type annotations. Pyright...
Read more >
Ten Most Common Metadata Errors - WV GIS Technical Center
Metadata experts have joined together to compile this list of common errors that are typically made when people create metadata records.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found