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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary to_dict() #834

Merged
merged 2 commits into from Feb 19, 2018

Conversation

Projects
None yet
3 participants
@Eldinnie
Member

Eldinnie commented Sep 16, 2017

We have some objects that have exactly the same to_dict() method, only specifying that from_user should be from in the data-dict. I refractored this logic to TelegramObject and removed those to_dicts() from the code.

remove unnecessary to_dict()
We have some objects that have exactly the same to_dict() method, only specifying that `from_user` should be `from` in the `data`-dict. I refractored this logic to `TelegramObject` and removed those to_dicts() from the code.
@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Sep 16, 2017

Codecov Report

Merging #834 into master will decrease coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #834      +/-   ##
==========================================
- Coverage   91.44%   91.23%   -0.22%     
==========================================
  Files         101      101              
  Lines        4023     4004      -19     
  Branches      614      615       +1     
==========================================
- Hits         3679     3653      -26     
- Misses        200      208       +8     
+ Partials      144      143       -1
Flag Coverage Δ
#Appveyor 86.28% <100%> (-0.07%) ⬇️
#Travis 90.85% <100%> (-0.22%) ⬇️
Impacted Files Coverage Δ
telegram/payment/shippingquery.py 100% <ø> (ø) ⬆️
telegram/payment/precheckoutquery.py 100% <ø> (ø) ⬆️
telegram/inline/inlinequery.py 100% <ø> (ø) ⬆️
telegram/callbackquery.py 100% <ø> (ø) ⬆️
telegram/choseninlineresult.py 100% <ø> (ø) ⬆️
telegram/message.py 96% <ø> (-0.02%) ⬇️
telegram/base.py 100% <100%> (ø) ⬆️
telegram/error.py 86.48% <0%> (-5.41%) ⬇️
telegram/utils/request.py 63.7% <0%> (-4.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5614af1...d789562. Read the comment docs.

codecov bot commented Sep 16, 2017

Codecov Report

Merging #834 into master will decrease coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #834      +/-   ##
==========================================
- Coverage   91.44%   91.23%   -0.22%     
==========================================
  Files         101      101              
  Lines        4023     4004      -19     
  Branches      614      615       +1     
==========================================
- Hits         3679     3653      -26     
- Misses        200      208       +8     
+ Partials      144      143       -1
Flag Coverage Δ
#Appveyor 86.28% <100%> (-0.07%) ⬇️
#Travis 90.85% <100%> (-0.22%) ⬇️
Impacted Files Coverage Δ
telegram/payment/shippingquery.py 100% <ø> (ø) ⬆️
telegram/payment/precheckoutquery.py 100% <ø> (ø) ⬆️
telegram/inline/inlinequery.py 100% <ø> (ø) ⬆️
telegram/callbackquery.py 100% <ø> (ø) ⬆️
telegram/choseninlineresult.py 100% <ø> (ø) ⬆️
telegram/message.py 96% <ø> (-0.02%) ⬇️
telegram/base.py 100% <100%> (ø) ⬆️
telegram/error.py 86.48% <0%> (-5.41%) ⬇️
telegram/utils/request.py 63.7% <0%> (-4.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5614af1...d789562. Read the comment docs.

@jsmnbom

I'm a bit conflicted with this change. On one hand it's a lot less duplicated code which is good most of the time. But on the other hand it's a bit unintuitive to have "from/from_user" be the only thing special thing that's handled in the base. I personally think it makes more sense to have it where it was before, despite the duplicated code.

Show outdated Hide outdated telegram/callbackquery.py
@Eldinnie

This comment has been minimized.

Show comment
Hide comment
@Eldinnie

Eldinnie Sep 16, 2017

Member

@bomjacob I fixed the indentation as you requested.
The reason I think from/from_user is an exception, is because it's the only one we rename in the library. And because it's the only one occurring more then once where it's the only reason to_dict exists.

Member

Eldinnie commented Sep 16, 2017

@bomjacob I fixed the indentation as you requested.
The reason I think from/from_user is an exception, is because it's the only one we rename in the library. And because it's the only one occurring more then once where it's the only reason to_dict exists.

@jsmnbom

Alright, I can see that, LGTM then :)

@tsnoam tsnoam added this to the 9.0 milestone Oct 20, 2017

@tsnoam tsnoam merged commit 0bed087 into master Feb 19, 2018

5 checks passed

codeclimate 5 fixed issues
Details
codecov/patch 100% of diff hit (target 91.44%)
Details
codecov/project Absolute coverage decreased by -0.21% but relative coverage increased by +8.55% compared to 5614af1
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@tsnoam tsnoam deleted the less-to-dict branch Feb 19, 2018

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