ni / nidaqmx-python

A Python API for interacting with NI-DAQmx
Other
434 stars 154 forks source link

types.py makes local debugging difficult #602

Open mshafer-NI opened 3 months ago

mshafer-NI commented 3 months ago

When attempting to run a single script, the cwd (which is vscode will be the folder of the script) is considered for imports first. This causes Python to import ./types when expecting to import stdlib types (https://docs.python.org/3/library/types.html).

This violates [O.2.1] ❌ DO NOT Redefine or “shadow” declarations

bkeryan commented 3 months ago

@mshafer-NI Does this affect users of nidaqmx-python or does it only affect developers working on nidaqmx-python? For users, the current directory should be outside the nidaqmx package.

nidaqmx/types.py has been there since the beginning: https://github.com/ni/nidaqmx-python/blob/0.5.2/nidaqmx/types.py . Renaming nidaqmx.types to something else would break compatibility. If this affects users, would it be acceptable to rename the submodule to _types.py and alias it in nidaqmx/__init__.py?

import _types as types

__all__ = [..., "types"]
mshafer-NI commented 3 months ago

It only affects developers (as clients are not expected to be working IN the library folder).

import _types as types

__all__ = [..., "types"]

This is a good solution