Skip to content
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 Python 2 crumbs #35

Merged
merged 8 commits into from
Apr 19, 2024
Merged

remove Python 2 crumbs #35

merged 8 commits into from
Apr 19, 2024

Conversation

a-detiste
Copy link
Contributor

Hi, I hope you like it.

cgi is being removed in Python 3.13(?), I'll look at it later

"mock is now part of the Python standard library, available as unittest.mock in Python 3.3 onwards."

https://github.com/testing-cabal/mock

Copy link
Owner

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

Thank you!

porting/test.py Show resolved Hide resolved
porting/test.py Show resolved Hide resolved
@@ -172,7 +159,7 @@ def search_irc_logs(query, stats=None, where=DEFAULT_LOGFILE_PATH,
elif event == LogParser.NICKCHANGE:
text, oldnick, newnick = info
else:
text = unicode(info)
text = str(info)
Copy link
Owner

Choose a reason for hiding this comment

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

TBH at this point info should already be Unicode, so

Suggested change
text = str(info)
text = info

should work fine.

I'm not sure why the old code was doing unicode(). Maybe to avoid hard errors in case I introduce a new event type that returns a tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't hurt either ... I don't know enough. The defaukt thing I would do for my projects is adding annotations everywhere.

Comment on lines 37 to 40
elif isinstance(o, str):
return repr(o).lstrip('u')
else:
return repr(o)
Copy link
Owner

Choose a reason for hiding this comment

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

There's no need to .lstrip('u') on Python 3, so this simplifies down to

Suggested change
elif isinstance(o, str):
return repr(o).lstrip('u')
else:
return repr(o)
else:
return repr(o)

src/irclog2html/tests/test_irclogsearch.py Show resolved Hide resolved
@mgedmin
Copy link
Owner

mgedmin commented Apr 18, 2024

cgi is being removed in Python 3.13(?), I'll look at it later

CGI support might have to be dropped. Luckily, I added WSGI support a while back. I think it'll be mostly documentation changes, some code removal, and a major version bump.

except NameError:
# Python 3.x
unicode = str


Copy link
Owner

Choose a reason for hiding this comment

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

flake8 says

src/irclog2html/irclogsearch.py:49:1: E303 too many blank lines (3)

(and I cannot stop thinking that there ought to be a way to have GitHub Actions run a linter and annotate the actual diff with the comments, but I've never seen it done for a Python project.)

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Owner

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I'm seeing CI failures in AppVeyor, but I don't see how they could be caused by your changes. I'll investigate.

@mgedmin
Copy link
Owner

mgedmin commented Apr 19, 2024

Git bisect blames commit 3d8ab24.

Oh! It's because the two elif isinstance(o, str): at the end of myrepr() should be plain else: clauses! I missed that during review (and this is why tests are good).

@a-detiste
Copy link
Contributor Author

Hi.

I can fix this when I m back on Tuesday.

Thanks for finding this out, I was confused.

"less is more"

I'm doing this through GitHub's review UI, and I have doubts that it will remove the correct number of blank lines (2).
@mgedmin mgedmin merged commit fd09b67 into mgedmin:master Apr 19, 2024
12 checks passed
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