[
https://issues.apache.org/jira/browse/BEAM-7746?focusedWorklogId=336530&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-336530
]
ASF GitHub Bot logged work on BEAM-7746:
----------------------------------------
Author: ASF GitHub Bot
Created on: 30/Oct/19 23:30
Start Date: 30/Oct/19 23:30
Worklog Time Spent: 10m
Work Description: chadrik commented on pull request #9056: [BEAM-7746]
Add python type hints
URL: https://github.com/apache/beam/pull/9056#discussion_r340904610
##########
File path: sdks/python/.pylintrc
##########
@@ -143,6 +143,7 @@ disable =
unnecessary-lambda,
unnecessary-pass,
unneeded-not,
+ unsubscriptable-object,
Review comment:
```python
class _ListBuffer(List[bytes]):
"""Used to support parititioning of a list."""
def partition(self, n):
# type: (int) -> List[List[bytes]]
return [self[k::n] for k in range(n)] # <------ ERROR HERE
```
```python
def progress_metrics(self):
# type: () -> beam_fn_api_pb2.Metrics.PTransform
with self.lock:
metrics = super(SdfProcessSizedElements, self).progress_metrics()
current_element_progress = self.current_element_progress()
if current_element_progress:
assert self.input_info is not None
metrics.active_elements.measured.input_element_counts[
self.input_info[1]] = 1 # <------ ERROR HERE
metrics.active_elements.fraction_remaining = (
current_element_progress.fraction_remaining)
return metrics
```
Generally speaking, there are a handful of checks that overlap between mypy
and pylint where pylint does a worse job. In the second example above
`self.input_info` is an `Optional[Tuple]` that's initialized to `None`, so it
thinks it's unsubscriptable, but it's initialized to a tuple elsewhere and
there's a line just above the error that says `assert self.input_info is not
None`. These are all subtleties that mypy understands but pylint does not.
> Perhaps a newer version of pylint could help?
I'm already using the latest and greatest (one of the commits here ticks the
version up from 2.4.2 to 2.4.3)
----------------------------------------------------------------
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: 336530)
Time Spent: 15h 40m (was: 15.5h)
> 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: 15h 40m
> 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)