Skip to content

added filter warnings for older versions of python (<3.7)#11396

Merged
Carreau merged 1 commit into
ipython:masterfrom
LucianaMarques:master
Oct 14, 2018
Merged

added filter warnings for older versions of python (<3.7)#11396
Carreau merged 1 commit into
ipython:masterfrom
LucianaMarques:master

Conversation

@LucianaMarques

Copy link
Copy Markdown
Contributor

I simply added the

if sys.info_version < (3,7):
...code

mentioned in this issue on the init_deprecation_warnings() functions in the main IPython class. What i understood is that this issue is fixed for python 3.7 but not for older versions, so I guessed this should suffice.

I wanted opinions from more experienced developers in this project to help to check it and to test it.

Comment thread IPython/core/interactiveshell.py Outdated
"""
warnings.filterwarnings("default", category=DeprecationWarning, module=self.user_ns.get("__name__"))
#warnings.filterwarnings("default", category=DeprecationWarning, module=self.user_ns.get("__name__"))
if sys.version_info < 3.7:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Change to:

if sys.version_info < (3, 7)

This is becasuse sys.version_info on py3 does not support the < operator (or that is my conclussion)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok! Doing it right now.

My biggest concern actually was if it resolved what the issue implied. How can I test my code?

@Carreau

Carreau commented Oct 14, 2018

Copy link
Copy Markdown
Member

Thanks !

You did commit all your .idea file though. See here on how to create a global git ignore file, and add .idea to it.

Then we can walk through how to squash your history for those files to not be added to repo.

If you code work on Python 3.7 at the REPL you should see the following:

In [1]: import warnings
   ...: def foo():
   ...:     warnings.warn('OH Noooo', DeprecationWarning)
   ...:

In [2]: foo()
/Users/bussonniermatthias/anaconda/bin/ipython:3: DeprecationWarning: OH Noooo
  __requires__ = 'ipython'

"""
warnings.filterwarnings("default", category=DeprecationWarning, module=self.user_ns.get("__name__"))
if sys.version_info < (3,7):
warnings.filterwarnings("default", category=DeprecationWarning, module=self.user_ns.get("__name__"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 Good job !

@Carreau

Carreau commented Oct 14, 2018

Copy link
Copy Markdown
Member

Good job, and thanks @eamanu for the review !

@LucianaMarques

Copy link
Copy Markdown
Contributor Author

Thank you @Carreau ! I'm new to pull requests, so thank you for sending me this tutorial.

I'll come back with changes in a bit.

@Carreau

Carreau commented Oct 14, 2018

Copy link
Copy Markdown
Member

Feel free to ask if you want more guidance. I'll stay short on purpose – to gitve you the opportunity to figure it out by yourself –  but I can give you detailed instructions if needed.

@LucianaMarques

Copy link
Copy Markdown
Contributor Author

Thank you @Carreau !
What I did so far:

  1. created a global .gitignore_global
  2. added ./idea to ir

It wasn't working properly, though, because I had to remove the files from git's tracking. I removed them with git rm -rf .idea and it said that the files inside the folder were succesfully removed. But whenever I tried to commit and push, the repository was already up-to-date.

  1. so I decided to exclude the ./idea folder

and it worked.

Does this sound right? Is there a better way to do it?

Thanks

@Carreau

Carreau commented Oct 14, 2018

Copy link
Copy Markdown
Member

It's good, let me show you how to rewrite the history to have only one clean commit and not have the intermediate .idea files in history.

We'll rebase interactive (-i) and squash (s) the last two commits

$ git rebase -i HEAD~3
<vim open if you haven't set $EDITOR>
<press i and Edit the second and third line, replace "pick" by "s">
<press ESC : w q Enter>
< write your new commit message>

Now you can force push.

Here is it as a gif.

rebase example

If it's too complicated I can do that for you.

@eamanu

eamanu commented Oct 14, 2018

Copy link
Copy Markdown

Great!

This is a "squash" of three commits into one. This means that the intermediate history has been rewritten.
@LucianaMarques

Copy link
Copy Markdown
Contributor Author

Hi there @Carreau !

Thank you for the help, I believe I did successfully what you asked for. This GIF is great!

What are the next steps now? should we do some more testing?

@LucianaMarques

Copy link
Copy Markdown
Contributor Author

Great!

Than you @eamanu !

@Carreau Carreau added this to the 7.1 milestone Oct 14, 2018
@Carreau

Carreau commented Oct 14, 2018

Copy link
Copy Markdown
Member

What are the next steps now? should we do some more testing?

No more step for this issue that you. For this specific issue I don't think more testing is necessary I'll just update 11333 so that once we drop 3.6 the code can actually be removed.... but that will take a couple of years.

Good job!

@Carreau
Carreau merged commit 8ed6e67 into ipython:master Oct 14, 2018
@LucianaMarques

Copy link
Copy Markdown
Contributor Author

Good job!

@Carreau thank you! Now I'm looking for more issues to work on, do you have any suggestions?

@Carreau

Carreau commented Oct 15, 2018

Copy link
Copy Markdown
Member

do you have any suggestions?

Not particularly, I'll have to go through and figure out if issues are easy or hard.

You can try to go through the list of what is needed for 7.1 release some of them have been fixed and just need to be closed.

You should be able to also apply a subset of labels to issues by gently asking our bot like so:

@meeseeksdev tag hacktoberfest

I'll try to mark a few issue as "good first issue" and/or "help wanted"

@lumberbot-app lumberbot-app Bot added the Hacktoberfest you want to participate to hacktoberfest ? Here is an easy issue. label Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hacktoberfest you want to participate to hacktoberfest ? Here is an easy issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants