[
https://issues.apache.org/jira/browse/BEAM-7746?focusedWorklogId=348340&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-348340
]
ASF GitHub Bot logged work on BEAM-7746:
----------------------------------------
Author: ASF GitHub Bot
Created on: 22/Nov/19 20:20
Start Date: 22/Nov/19 20:20
Worklog Time Spent: 10m
Work Description: chadrik commented on pull request #9915: [BEAM-7746]
Add python type hints (part 1)
URL: https://github.com/apache/beam/pull/9915#discussion_r349778574
##########
File path: sdks/python/apache_beam/transforms/window.py
##########
@@ -505,7 +527,8 @@ def get_window_coder(self):
return coders.IntervalWindowCoder()
def merge(self, merge_context):
- to_merge = []
+ # type: (WindowFn.MergeContext) -> None
+ to_merge = [] # type: List[Union[IntervalWindow, GlobalWindow]]
Review comment:
Changing this and the other use of `Union[IntervalWindow, GlobalWindow]` to
`BoundedWindow` results in these errors:
```
apache_beam/transforms/window.py:541: error: "BoundedWindow" has no
attribute "start" [attr-defined]
apache_beam/transforms/window.py:543: error: "BoundedWindow" has no
attribute "start" [attr-defined]
apache_beam/transforms/window.py:550: error: "BoundedWindow" has no
attribute "start" [attr-defined]
apache_beam/transforms/window.py:557: error: "BoundedWindow" has no
attribute "start" [attr-defined]
```
The docs for `BoundedWindow` say that it's for timestamps in the range
(-infinity, end).
How about we add a `start` property to `BoundedWindow`:
```python
class BoundedWindow(object):
"""A window for timestamps in range (-infinity, end).
Attributes:
end: End of window.
"""
def __init__(self, end):
# type: (Union[int, float, Timestamp]) -> None
self._end = Timestamp.of(end)
@property
def start(self):
# type: () -> Timestamp
return MAX_TIMESTAMP
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 348340)
Time Spent: 29h 10m (was: 29h)
> Add type hints to python code
> -----------------------------
>
> Key: BEAM-7746
> URL: https://issues.apache.org/jira/browse/BEAM-7746
> Project: Beam
> Issue Type: New Feature
> Components: sdk-py-core
> Reporter: Chad Dombrova
> Assignee: Chad Dombrova
> Priority: Major
> Time Spent: 29h 10m
> Remaining Estimate: 0h
>
> As a developer of the beam source code, I would like the code to use pep484
> type hints so that I can clearly see what types are required, get completion
> in my IDE, and enforce code correctness via a static analyzer like mypy.
> This may be considered a precursor to BEAM-7060
> Work has been started here: [https://github.com/apache/beam/pull/9056]
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)