Qcodes icon indicating copy to clipboard operation
Qcodes copied to clipboard

VisaInstrument replace kwargs with metadata

Open jenshnielsen opened this issue 3 years ago • 7 comments

VisaInstrument used to take kwargs but actually the only non explicit argument is metadata so we might as well write that out.

jenshnielsen avatar Aug 01 '22 13:08 jenshnielsen

Codecov Report

Merging #4445 (b5dd89c) into master (b5dd89c) will not change coverage. The diff coverage is n/a.

:exclamation: Current head b5dd89c differs from pull request most recent head e28905d. Consider uploading reports for the commit e28905d to get more accurate results

@@           Coverage Diff           @@
##           master    #4445   +/-   ##
=======================================
  Coverage   68.05%   68.05%           
=======================================
  Files         290      290           
  Lines       31314    31314           
=======================================
  Hits        21312    21312           
  Misses      10002    10002           

codecov[bot] avatar Aug 01 '22 13:08 codecov[bot]

I dont think so. Instrument did not take and more kwargs so that would just throw. I guess it could throw in multiple inheritance?

jenshnielsen avatar Aug 01 '22 15:08 jenshnielsen

I guess it could throw in multiple inheritance?

oh, that's even a better catch. need to write a test to check....

astafan8 avatar Aug 01 '22 15:08 astafan8

@astafan8 I mean the following will certainly break.

class Foo

   def __init__(fooness=None, **kwargs):
       self._fooness = fooness
       super().__init__(**kwargs)


class Bar(VisaInstrument, Foo)

    def __init__(name, **kwargs)
         super().__init__(name, **kwargs)


bar = Bar(name="bar", address="someaddr", fooness="max")

so if we care about that we should not make the change

jenshnielsen avatar Aug 01 '22 18:08 jenshnielsen

so if we care about that we should not make the change

i do hope that we don't care :) we could try to release with this change and revert it if someone reports a breakage. or reserve this change for the v1.0 times :)

astafan8 avatar Aug 02 '22 07:08 astafan8

@astafan8 We could also be more defensive and add metadata as a keyword argument and trigger a warning if len(kwargs) > 0

jenshnielsen avatar Aug 02 '22 08:08 jenshnielsen

We could also be more defensive and add metadata as a keyword argument and trigger a warning if len(kwargs) > 0

ah! great idea, i support this :)

astafan8 avatar Aug 02 '22 09:08 astafan8