microsoft / microsoft/Qcodes

Port usage of add_submodule to assign to an attribute

Open
#7,154 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

Now that add_submodule returns the newly created submodule we should update all instrument drivers in src/qcodes/instrument_drivers to make use of this.

This means that as an example a line like

```
self.add_submodule("correction", KeysightB1500Correction(self, "correction"))
```

should be replaced by

```
self.correction: KeysightB1500Correction = self.add_submodule("correction", KeysightB1500Correction(self, "correction"))
"""
Instrument module correction
"""
```

e.g the attribute should be assigned to the same value as the name argument, the type should be included and a docstring added after the attribute.

In the first round we should only do this for attributes where the name can be known statically and not try to do this when the name is dynamically created. E.g. We want to avoid using `__setattr__`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the usages of add_submodule under src/qcodes/instrument_drivers and identify calls whose name argument is statically known. Update those attributes to assign the returned submodule with the matching type and add the requested docstring, while leaving dynamically named cases unchanged. Done means all eligible instrument-driver usages follow the documented pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.