Skip to content

Drop use of .has_key(); deprecated in modern Python #137

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

Closed
wants to merge 0 commits into from
Closed

Drop use of .has_key(); deprecated in modern Python #137

wants to merge 0 commits into from

Conversation

jdufresne
Copy link
Member

Using the in operator is preferred and available on all supported versions of Python.

From https://docs.python.org/3/whatsnew/3.0.html#builtins

Removed. dict.has_key() – use the in operator instead.

Copy link
Member

@tiran tiran left a comment

Choose a reason for hiding this comment

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

I'm afraid we cannot remove the function as long as we support Python 2. The removal breaks backwards compatibility without any benefits for the user.

@encukou
Copy link
Member

encukou commented Dec 18, 2017

Indeed. On Python 2, has_key needs to stay.

@jdufresne
Copy link
Member Author

Should I add a warning for its eventual removal?

Python 2.7 users can continue to use the in operator. It is supported.

@encukou encukou added this to the 3.1 milestone Dec 20, 2017
@encukou
Copy link
Member

encukou commented Dec 21, 2017

Should I add a warning for its eventual removal?

Yes, a DeprecationWarning sounds good. But I wouldn't rush the removal itself. Let's say we'll remove it when Python 2 support is dropped?

@tiran
Copy link
Member

tiran commented Dec 21, 2017

We could only add the function under Python 2 and not define it under Python 3.

@encukou
Copy link
Member

encukou commented Dec 21, 2017

We could only add the function under Python 2 and not define it under Python 3.

We are past the stage of defining an API for python-ldap 3.0.

Sure, has_key looks ugly and backwards and "the wrong way to do it", and a good linter will complain you about it... but it's there, it's tested, it's not a source of subtle bugs, and it doesn't really cost anything to keep it.
Let's make it clear it's not the way to do things, but avoid breaking people's code for purity's sake.

@codecov
Copy link

codecov bot commented Dec 22, 2017

Codecov Report

Merging #137 into master will increase coverage by <.01%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #137      +/-   ##
==========================================
+ Coverage   69.35%   69.35%   +<.01%     
==========================================
  Files          49       49              
  Lines        4708     4712       +4     
  Branches      800      800              
==========================================
+ Hits         3265     3268       +3     
- Misses       1088     1089       +1     
  Partials      355      355
Impacted Files Coverage Δ
Lib/ldap/schema/models.py 70.81% <0%> (-0.26%) ⬇️
Lib/ldap/cidict.py 69.23% <100%> (+1.23%) ⬆️
Lib/ldif.py 75.96% <0%> (ø) ⬆️
Lib/ldap/modlist.py 84.9% <0%> (+0.29%) ⬆️

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 98c535b...f156d07. Read the comment docs.

@jdufresne
Copy link
Member Author

Updated. Restored function. Now issues a warning.

@encukou encukou closed this Jan 5, 2018
@encukou
Copy link
Member

encukou commented Jan 5, 2018

Hi @jdufresne,
Embarrassingly, when I was rebasing your other pull request to get rid of conflicts, I managed to overwrite your branch here.
Could you please push your changes again?
I'm sorry for this. I'll be more careful in the future.

@jdufresne
Copy link
Member Author

No worries. Done in #151 Thanks

@encukou
Copy link
Member

encukou commented Jan 5, 2018

That's not the one. Could you push your local branch drop-has-key to GitHub?

@jdufresne
Copy link
Member Author

Oops, sorry about that. Lets try that again, #153

@encukou
Copy link
Member

encukou commented Jan 5, 2018

Thank you! The change looks good; I'll do a full review next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy