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

Correct data type of start date #22

Closed
felix-seifert opened this issue Apr 8, 2023 · 4 comments
Closed

Correct data type of start date #22

felix-seifert opened this issue Apr 8, 2023 · 4 comments

Comments

@felix-seifert
Copy link
Collaborator

When I try to generate example roadmaps, I sometimes get the error message TypeError: strptime() argument 1 must be str, not datetime.datetime for the method set_timeline. However, I pass the argument of the start date as "2023-01-01", which should be a string. Naming the argument (start="2023-01-01") often seems to work.

The issue is that method expects a datetime while it seems to be okay (and common) to pass it a str. If I look through the source code, the argument is usually passed as a str (while the method expects a datetime). To introduce some more consistency, the expected value should be a str which will then be transformed to a datetime internally.

@csgoh
Copy link
Owner

csgoh commented Apr 9, 2023

Can you provide the code that is able to reproduce the error?

@felix-seifert
Copy link
Collaborator Author

I think that I mixed up two problems which give me the same error above. 🙈

The first problem is that it does not work to pass the start date as a datetime (which is expected).

    roadmap = Roadmap(1200, 1000)
    roadmap.set_title("STRATEGY ROADMAP 2023")

    roadmap.set_timeline(
        TimelineMode.MONTHLY,
        datetime.strptime("2022-12-01", "%Y-%m-%d"),
    )

When I give the start date as a str like "2022-12-01", everything works fine.

The second problem is that I get the above error message if I omit the TimelineMode as in the following example.

    roadmap = Roadmap(1200, 1000)
    roadmap.set_title("STRATEGY ROADMAP 2023")

    roadmap.set_timeline(
        "2022-12-01",
    )

Passing the mode is optional and it is therefore clear that I have to pass the argument as start="2022-12-01". However, the error message seems to be slightly off and not very helpful.

@csgoh
Copy link
Owner

csgoh commented Apr 19, 2023

Yeah, that is the problem when the first argument is optional. Let me think about whether I should enforce keyword argument.

@csgoh
Copy link
Owner

csgoh commented Apr 23, 2023

I have added keyword argument for date. You will need to pass in start="2023-04-24" when calling add_timeline() method.

@csgoh csgoh closed this as completed Apr 23, 2023
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

No branches or pull requests

2 participants