Algorithm metadata causes pyright reportUnusedVariable errors
See original GitHub issueIn 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
:
- add
type: ignore[reportUnusedVariable]
to each line, - configure pyright to ignore these
__init__.py
files entirely, or - Wrap the metadata fields in a
MetaData
class decorated with@no_type_check
(and updatecomposer.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:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Discussed offline with @dblalock , and he prefers the
json
approach. Declutters the python namespace and makes it accessible outside. Will implement a fix here.I like the
MetaData
class. Embedding directly in the class-level attributes would clutter the namespace with attributes not really used by developers.