[ 
https://issues.apache.org/jira/browse/BEAM-7746?focusedWorklogId=335144&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-335144
 ]

ASF GitHub Bot logged work on BEAM-7746:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Oct/19 20:01
            Start Date: 28/Oct/19 20:01
    Worklog Time Spent: 10m 
      Work Description: chadrik commented on issue #9056: [BEAM-7746] Add 
python type hints
URL: https://github.com/apache/beam/pull/9056#issuecomment-547119254
 
 
   > when we switch to python 3, is there a tool that will convert all the type 
comments to pep 484 type hints?
   
   Yes.  https://github.com/ilevkivskyi/com2ann.  I think we will need to 
manually fixup a bunch of style issues after running that, because when the 
comments become annotations they will exceed the line limit.   
   
   Side note: I recently experimented with enabling pylint's auto-fix features 
(like spotlessApply), but it won't work unless we're willing to change Beams' 
rather "unique" style.  IIRC, the main deal-breaker is Beams' mixture of 
2-space and 4-space tabs depending on context (it's been a headache for me to 
setup properly in PyCharm as well.  I have something that's close, but not 
perfect).
   
   EDIT:  I just saw the script includes an option to automatically wrap 
signatures, `--wrap-signatures MAX_LENGTH`, but even with this enabled there 
will be lines that exceed the length limit due to arguments with 
complex/compound types.  But that feature will definitely save a lot of time!
   
   > In terms of getting this reviewed, I understand that mypy can't be enabled 
[1] until it's all in, but I think it's preferable to get individual commits 
merged and in incrementally than review commits incrementally and then try to 
get them all in at once in a single PR. In my spot checking it seems these 
commits are relatively orthogonal--is that basically the case? Perhaps a 
reviewer could create PRs cherry-picking commits that they are able to review 
in one sitting and we could get them in that way? Any other ideas?
   
   I like the idea of adding the lint job but not failing until we've gotten 
everything in. 
   
   There are some commits that depend on others, but the relationship is not 
always obvious, even to me.  
   
   How about this plan: we first merge in a PR that contains just type 
comments, so theoretically no chance of runtime changes.  This will be ignore 
comments, base typing pass, and the mypy lint job with failure disabled  
(basically this PR through to 
https://github.com/apache/beam/pull/9056/commits/c25792c83785bce1ed4b01dd531ee1404b899438).
  At this point I think it would be safe for reviewers to cherry-pick the more 
topical commits that remain, in any order they choose. 
   
   
 
----------------------------------------------------------------
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: 335144)
    Time Spent: 11h 40m  (was: 11.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: 11h 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)

Reply via email to