Correct data type of start date
felix-seifert opened this issue · comments
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.
Can you provide the code that is able to reproduce the error?
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.
Yeah, that is the problem when the first argument is optional. Let me think about whether I should enforce keyword argument.
I have added keyword argument for date. You will need to pass in start="2023-04-24"
when calling add_timeline()
method.