Opened 16 months ago
Closed 16 months ago
#34809 closed Uncategorized (duplicate)
PyCharm typechecker complains
Reported by: | Nils Lindemann | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 4.2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
#30345 was closed, probably because it was not clear that the code will run, but the PyCharm type checker will complain. The solution posted there, namely, to write ...
return self.pub_date >= (timezone.now() - datetime.timedelta(days=1)).timestamp()
... instead of ...
return self.pub_date >= timezone.now() - datetime.timedelta(days=1) # PyCharm complains: "Expected type 'timedelta', got 'DateTimeField' instead"
... will result in the correct type returned and PyCharm will not complain anymore.
The related code example in the docs.
See also this Stack Overflow question.
Change History (3)
comment:1 by , 16 months ago
Summary: | Pycharm typechecker complains → PyCharm typechecker complains |
---|
comment:2 by , 16 months ago
comment:3 by , 16 months ago
Component: | Uncategorized → Documentation |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
Duplicate of #30345. Please leave a comment on the original ticket, if you like. I don't know why PyCharm is complaining but I don't see any issue here.
If someone could let me know where these docs are stored on GitHub, I can create a PR.