Skip to content

Commit

Permalink
codegen, handwritten: Use tuple for empty __slots__
Browse files Browse the repository at this point in the history
Work around python/mypy#10870 - Mypy complains
when [] is used for __slots__ definition

generated\nidaqmx\_base_interpreter.py:8: error: Need type annotation for "__slots__" (hint: "__slots__: List[<type>] = ...")  [var-annotated]

Signed-off-by: Brad Keryan <brad.keryan@ni.com>
  • Loading branch information
bkeryan committed Jun 6, 2023
1 parent 233833f commit 84a5cf8
Show file tree
Hide file tree
Showing 30 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions generated/nidaqmx/_base_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BaseEventHandler(abc.ABC):
"""Interpreter-specific object that is returned from register_*_event()."""
__slots__ = []
__slots__ = ()

@abc.abstractmethod
def close(self) -> None:
Expand All @@ -21,7 +21,7 @@ class BaseInterpreter(abc.ABC):
"""
Contains signature of functions for all DAQmx APIs.
"""
__slots__ = []
__slots__ = ()

@abc.abstractmethod
def add_cdaq_sync_connection(self, port_list):
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LibraryInterpreter(BaseInterpreter):
"""
# Do not add per-task state to the interpreter class.
__slots__ = []
__slots__ = ()

def __init__(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/ai_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AIChannel(Channel):
"""
Represents one or more analog input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'AIChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/ao_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AOChannel(Channel):
"""
Represents one or more analog output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'AOChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/ci_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CIChannel(Channel):
"""
Represents one or more counter input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'CIChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/co_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class COChannel(Channel):
"""
Represents one or more counter output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'COChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/di_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DIChannel(Channel):
"""
Represents one or more digital input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'DIChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/_task_modules/channels/do_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DOChannel(Channel):
"""
Represents one or more digital output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'DOChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class _ScaleAlternateConstructor(Scale):
This is a private API used to instantiate a Scale with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ class _DeviceAlternateConstructor(Device):
This is a private API used to instantiate a Device with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/physical_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ class _PhysicalChannelAlternateConstructor(PhysicalChannel):
This is a private API used to instantiate a PhysicalChannel with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/storage/persisted_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _PersistedChannelAlternateConstructor(PersistedChannel):
This is a private API used to instantiate a PersistedChannel with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/storage/persisted_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class _PersistedScaleAlternateConstructor(PersistedScale):
This is a private API used to instantiate a PersistedScale with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/system/storage/persisted_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _PersistedTaskAlternateConstructor(PersistedTask):
This is a private API used to instantiate a PersistedTask with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ class _TaskAlternateConstructor(Task):
This is a private API used to instantiate a Task with an existing task handle and interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, task_handle, interpreter, close_on_exit):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/templates/_base_interpreter.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from typing import Optional

class BaseEventHandler(abc.ABC):
"""Interpreter-specific object that is returned from register_*_event()."""
__slots__ = []
__slots__ = ()

@abc.abstractmethod
def close(self) -> None:
Expand All @@ -31,7 +31,7 @@ class BaseInterpreter(abc.ABC):
"""
Contains signature of functions for all DAQmx APIs.
"""
__slots__ = []
__slots__ = ()

% for func in functions:
<%
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/templates/_library_interpreter.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LibraryInterpreter(BaseInterpreter):

"""
# Do not add per-task state to the interpreter class.
__slots__ = []
__slots__ = ()

def __init__(self):
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AIChannel(Channel):
"""
Represents one or more analog input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'AIChannel(name={self._name})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AOChannel(Channel):
"""
Represents one or more analog output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'AOChannel(name={self._name})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CIChannel(Channel):
"""
Represents one or more counter input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'CIChannel(name={self._name})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class COChannel(Channel):
"""
Represents one or more counter output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'COChannel(name={self._name})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DIChannel(Channel):
"""
Represents one or more digital input virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'DIChannel(name={self._name})'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DOChannel(Channel):
"""
Represents one or more digital output virtual channels and their properties.
"""
__slots__ = []
__slots__ = ()

def __repr__(self):
return f'DOChannel(name={self._name})'
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/templates/scale.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class _ScaleAlternateConstructor(Scale):
This is a private API used to instantiate a Scale with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/templates/system/device.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class _DeviceAlternateConstructor(Device):
This is a private API used to instantiate a Device with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/templates/system/physical_channel.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _PhysicalChannelAlternateConstructor(PhysicalChannel):
This is a private API used to instantiate a PhysicalChannel with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/system/storage/persisted_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class _PersistedChannelAlternateConstructor(PersistedChannel):
This is a private API used to instantiate a PersistedChannel with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/system/storage/persisted_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class _PersistedScaleAlternateConstructor(PersistedScale):
This is a private API used to instantiate a PersistedScale with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/system/storage/persisted_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class _PersistedTaskAlternateConstructor(PersistedTask):
This is a private API used to instantiate a PersistedTask with an existing interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, name, interpreter):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ class _TaskAlternateConstructor(Task):
This is a private API used to instantiate a Task with an existing task handle and interpreter.
"""
# Setting __slots__ avoids TypeError: __class__ assignment: 'Base' object layout differs from 'Derived'.
__slots__ = []
__slots__ = ()

def __init__(self, task_handle, interpreter, close_on_exit):
"""
Expand Down

0 comments on commit 84a5cf8

Please sign in to comment.