Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong dataclass AuthorizationData (v1.6) #412

Closed
tzzdvd opened this issue Jan 24, 2023 · 2 comments
Closed

Wrong dataclass AuthorizationData (v1.6) #412

tzzdvd opened this issue Jan 24, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@tzzdvd
Copy link

tzzdvd commented Jan 24, 2023

Based on the documentation on section "7.1. AuthorizationData", this class has the idTagInfo field Optional

In file ocpp.v16.datatypes.py, the field is actually optional but the default is missing

current version (0.16.0)

@dataclass
class AuthorizationData:
    """
    Elements that constitute an entry of a Local Authorization List update.
    """

    id_tag: str
    id_tag_info: Optional[IdTagInfo]

In my opinion, it should be

@dataclass
class AuthorizationData:
    """
    Elements that constitute an entry of a Local Authorization List update.
    """

    id_tag: str
    id_tag_info: Optional[IdTagInfo] = None

Without that correction, the following code crashes

k = {"id_tag": "1234"}
k_dataclass = AuthorizationData(**k)

with

TypeError: AuthorizationData.__init__() missing 1 required positional argument: 'id_tag_info'

In the meantime, the only fix I have found at application level is

k = {"id_tag": "1234"}
if "id_tag_info" not in k:
    k["id_tag_info"] = None
k_dataclass = AuthorizationData(**k)

an no crashes occurs.

Best regards
Davide

@tzzdvd tzzdvd added the question Further information is requested label Jan 24, 2023
@zapoig
Copy link

zapoig commented Jun 9, 2023

I concur, this makes the removal of a badge in the local auth list by an incremental update impossible : it needs the id_tag_info not to be present.

Correction, not impossible : you can send a SendLocalList.req whose AuthorizationData list do not all contains an idTagInfo - you just have to make sure to initialize idTagInfo to None.

@Jared-Newell-Mobility Jared-Newell-Mobility added bug Something isn't working and removed question Further information is requested labels Sep 8, 2023
@Jared-Newell-Mobility
Copy link
Contributor

Nice catch id_tag_info should have the default of None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants