Skip to content

Upgrade to Python 3.7 and above #12

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

Merged
merged 5 commits into from
Oct 14, 2021
Merged

Upgrade to Python 3.7 and above #12

merged 5 commits into from
Oct 14, 2021

Conversation

gahjelle
Copy link
Collaborator

@gahjelle gahjelle commented Oct 3, 2021

Update the code to be more "modern". In particular:

  • Use type hints instead of type comments (Python 3.6+)
  • Use f-strings instead of .format() (Python 3.6+)
  • Use importlib.resources (Python 3.7+)
  • Use pathlib instead of os.path (Python 3.4+)

@gahjelle
Copy link
Collaborator Author

gahjelle commented Oct 3, 2021

@lpozo Here are some updates to bring us into the modern Python age 😊

Copy link

@lpozo lpozo left a comment

Choose a reason for hiding this comment

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

Hey @gahjelle!

The update LGTM!

I just have a few comments. Please, take a look at them and let me know if they look good to you.

Thanks for taking the time to do this!

Leodanis

README.md Outdated

The reader is supported on Python 2.7, as well as Python 3.4 and above.
The reader is supported on Python 3.7 and above. Older versions of Python, including Python 2.7, is supported by version 1.0.0 of the reader.
Copy link

Choose a reason for hiding this comment

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

Suggested change
The reader is supported on Python 3.7 and above. Older versions of Python, including Python 2.7, is supported by version 1.0.0 of the reader.
The reader is supported on Python 3.7 and above. Older versions of Python, including Python 2.7, are supported by version 1.0.0 of the reader.

from ConfigParser import ConfigParser as _ConfigParser

from configparser import ConfigParser
from importlib import resources

# Version of realpython-reader package
__version__ = "1.0.0"
Copy link

Choose a reason for hiding this comment

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

Should we update the version number?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but I usually don't do that in a PR like this. At least in a bigger project, there might be other commits coming in, etc. Instead, I usually bump the version as the first step in the release process.

reader/feed.py Outdated
@@ -9,32 +9,31 @@
# Reader imports
from reader import URL

_CACHED_FEEDS = dict() # type: Dict[str, feedparser.FeedParserDict]
_CACHED_FEEDS: Dict[str, feedparser.FeedParserDict] = dict()
Copy link

Choose a reason for hiding this comment

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

We already have info about the data type, so probably using a dict literal is more straightforward and faster.

Suggested change
_CACHED_FEEDS: Dict[str, feedparser.FeedParserDict] = dict()
_CACHED_FEEDS: Dict[str, feedparser.FeedParserDict] = {}



def main(): # type: () -> None
def main() -> None:
"""Read the Real Python article feed"""
Copy link

Choose a reason for hiding this comment

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

If we adhere to PEP 257, then this type of docstring should end in a period.

@gahjelle
Copy link
Collaborator Author

Thanks @lpozo

I've fixed the docstrings and the few other issues you mentioned. I propose that we handle the version number as part of the release to PyPI after this PR is merged (although the reference to v1.0.0 in README might seem inconsistent, it's still true in terms of what you get when installing from PyPI).

@lpozo
Copy link

lpozo commented Oct 13, 2021

Hey @gahjelle! The update LGTM! Thanks for taking the time to do this! I think you can merge the PR now.

@gahjelle gahjelle merged commit 0387003 into master Oct 14, 2021
@gahjelle gahjelle deleted the upgrade-to-py37 branch October 14, 2021 10:46
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.

2 participants