Skip to content

Conversation

@acolomb
Copy link
Member

@acolomb acolomb commented Jun 17, 2024

With commit 0285f58, the Map class was inadvertently removed from the imports directly available within the canopen.pdo package. However, it is referenced as canopen.pdo.PdoMap in the p402 module and documentation.

Restore that import using the new names PdoMap and PdoVariable. Move the compatibility define to the very bottom, just like in other modules. Provide an __all__ listing to clarify what constitutes the public API.

acolomb added 2 commits June 18, 2024 00:00
With commit 0285f58, the Map class
was inadvertently removed from the imports directly available within
the canopen.pdo package.  However, it is referenced as
canopen.pdo.PdoMap in the p402 module and documentation.

Restore that import using the new names PdoMap and PdoVariable.  Move
the compatibility define to the very bottom, just like in other
modules.  Provide an __all__ listing to clarify what constitutes the
public API.
Replace the sphinx parameter type documentation with a proper type
hint annotation.  Same for the tpdo_pointers and rpdo_pointers
attributes.
@acolomb acolomb changed the title Export PdoMap and PdoVariables classes in pdo module Export PdoMap and PdoVariable classes in pdo module Jun 17, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.23%. Comparing base (3600880) to head (c04b624).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #464      +/-   ##
==========================================
+ Coverage   67.20%   67.23%   +0.03%     
==========================================
  Files          26       26              
  Lines        3095     3098       +3     
  Branches      522      522              
==========================================
+ Hits         2080     2083       +3     
  Misses        873      873              
  Partials      142      142              
Files Coverage Δ
canopen/pdo/__init__.py 77.77% <100.00%> (+0.63%) ⬆️
canopen/profiles/p402.py 36.46% <60.00%> (+0.46%) ⬆️



# Compatibility
Variable = PdoVariable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if Variable should be listed in __all__. In principle __all__ contains the entire public API of the module. However, it's not very common to list objects defined in the file in __all__ is it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what's common practice with regard to that __all__ attribute. But my understanding is that it controls what from ... import * does. In that case, Variable should not be imported, as it is a deprecated alias only kept for compatibility. But if someone references it directly, that still works.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Svein:

However, it's not very common to list objects defined in the file in __all__ is it?

That's of course possible; for example, a sentinel or a singleton could also be a part of a public API.

André:

[...] my understanding is that it controls what from ... import * does.
[...] But if someone references it directly, that still works.

Both are correct. from canopen.pdo import Variable still works.

@acolomb acolomb merged commit 5734f37 into canopen-python:master Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants