Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

added type references to pager.py, mypy produced no errors#936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
thomasballinger merged 5 commits intobpython:mainfromFrostmaine:mypy_types
Nov 9, 2021
Merged

added type references to pager.py, mypy produced no errors#936

thomasballinger merged 5 commits intobpython:mainfromFrostmaine:mypy_types
Nov 9, 2021

Conversation

@Frostmaine
Copy link
Contributor

First time adding to a project on github, started off small. Would really appreciate feedback.

Copy link
Member

@thomasballingerthomasballinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for working on this!

It looks like some builds are failing becauselist can't be subscripted, I added a note about why.

When I run mypy, I get a few errors

$ python -m mypybpython/pager.py:57: error: Item "None" of "Optional[IO[bytes]]" has no attribute "write"bpython/pager.py:58: error: Item "None" of "Optional[IO[bytes]]" has no attribute "close"bpython/_internal.py:7: error: Incompatible types in assignment (expression has type "Callable[[str, bool], None]", variable has type "Callable[[str], None]")Found 3 errors in 2 files (checked 64 source files)

If you figure out how our environments are different let me know and maybe we can add it to some developer docs.

The bpython/_internal.py file is getting more strictly checked now because it usespage defined in pager.py. Apparently the real pydoc.pager doesn't take that second argument. I'd be fine with atype: ignore for that.

pydoc.pager = page  # type: ignore



defget_pager_command(default="less -rf"):
defget_pager_command(default:str="less -rf")->list[str]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unfortunately usinglist anddict in type annotations instead oftyping.List andtyping.Dict wasadded in 3.9 and bpython still supports 3.8 and 3.7, so we can't use these yet; you'll need to import List from typing and use that.

else:
curses.endwin()
try:
popen=subprocess.Popen(command,stdin=subprocess.PIPE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For me this needs a

Suggested change
popen=subprocess.Popen(command,stdin=subprocess.PIPE)
assertpopen.stdinisnotNone
popen=subprocess.Popen(command,stdin=subprocess.PIPE)

to silence mypy errors about stdin maybe being None.

@thomasballinger
Copy link
Member

thomasballinger commentedNov 2, 2021
edited
Loading

If you aren't able to get mypy to produce these errors locally, you can see them in the CI runs on this page.
image

@Frostmaine
Copy link
ContributorAuthor

Linter workflow did fail, however it seemed to only be because I modified _internal.py by adding the suggested # type: ignore to pydoc.pager = page.

@codecov-commenter
Copy link

codecov-commenter commentedNov 9, 2021
edited
Loading

Codecov Report

Merging#936 (72a126b) intomain (b4578ba) willincrease coverage by0.53%.
The diff coverage is62.50%.

Impacted file tree graph

@@            Coverage Diff             @@##             main     #936      +/-   ##==========================================+ Coverage   68.11%   68.65%   +0.53%==========================================  Files          61       62       +1       Lines        9244     9434     +190     ==========================================+ Hits         6297     6477     +180- Misses       2947     2957      +10
Impacted FilesCoverage Δ
bpython/pager.py26.82% <57.14%> (+1.18%)⬆️
bpython/_internal.py78.57% <100.00%> (ø)
bpython/line.py95.86% <0.00%> (-0.33%)⬇️
bpython/test/test_brackets_completion.py99.13% <0.00%> (ø)
bpython/config.py87.83% <0.00%> (+0.08%)⬆️
bpython/curtsiesfrontend/manual_readline.py90.15% <0.00%> (+0.20%)⬆️
bpython/curtsiesfrontend/repl.py65.83% <0.00%> (+0.72%)⬆️
bpython/autocomplete.py86.47% <0.00%> (+0.88%)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updateb4578ba...72a126b. Read thecomment docs.

@sebastinas
Copy link
Contributor

Indeed, theblack check failed. So please runblack onbpython/_internal.py and commit the fix.

@thomasballingerthomasballinger merged commitadf19b1 intobpython:mainNov 9, 2021
@thomasballinger
Copy link
Member

Thanks for adding these types and fixing these CI issues, this looks good to me. The pypy3 CI failure is failing on main right now too.

@Frostmaine
Copy link
ContributorAuthor

Frostmaine commentedNov 10, 2021 via email

Glad to complete my first contribution to a project that I use daily. Ihope to take the things I learned about the development process andcontinue to contribute in my own small way to this project. Any feedbackon how I have conducted my interactions with you are welcome. Thank you somuch for your time.
On Tue, Nov 9, 2021 at 11:17 AM Thomas Ballinger ***@***.***> wrote: Thanks for adding these types and fixing these CI issues, this looks good to me. The pypy3 CI failure is failing on main right now too. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#936 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AMQSM4JJNZPRYEKCE3TUYZ3ULFCSRANCNFSM5HEVBCTA> . Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
thomasballinger reacted with hooray emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@thomasballingerthomasballingerthomasballinger requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@Frostmaine@thomasballinger@codecov-commenter@sebastinas

[8]ページ先頭

©2009-2025 Movatter.jp