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

Refine the codebase #6

Open
bswck opened this issue Apr 18, 2024 · 9 comments
Open

Refine the codebase #6

bswck opened this issue Apr 18, 2024 · 9 comments
Assignees

Comments

@bswck
Copy link
Member

bswck commented Apr 18, 2024

No description provided.

@bswck bswck self-assigned this Apr 18, 2024
@jaraco
Copy link
Member

jaraco commented Apr 18, 2024

I've been doing this lately with ruff --select UP --fix. See also jaraco/skeleton#112, where we're looking to apply this constraint across all projects.

@diogobaeder
Copy link
Member

I'm all for automating the process, as long as we can have human reviews on the changes (e.g. PRs or review-before-push or so)

@bswck
Copy link
Member Author

bswck commented Apr 18, 2024

I don't see much to do here when it comes to Python 3.8 modernization precisely.
I'll then go ahead and say I'll generically improve the code quality.

@bswck bswck changed the title Modernize the codebase to Python 3.8+ Refine the codebase Apr 18, 2024
@diogobaeder
Copy link
Member

An idea would be to make use of things that were introduced in Python 3.8 but weren't available in earlier versions, where it makes sense. For example, in 3.6 dataclasses was an external library, and since 3.8 (IIRC) they became part of the stdlib. So we could cut out any reference to dataclasses as a library.

Type hinting also improved, so we could make use of that too I guess. What do you think?

@bswck bswck mentioned this issue Apr 18, 2024
@bswck
Copy link
Member Author

bswck commented Apr 18, 2024

I'll start from type hints.

@bswck
Copy link
Member Author

bswck commented Apr 18, 2024

For example, in 3.6 dataclasses was an external library, and since 3.8 (IIRC) they became part of the stdlib. So we could cut out any reference to dataclasses as a library.

Yeah, dataclasses was added to stdlib in 3.7. But I can see it between other stdlib imports here:

from copy import deepcopy
from dataclasses import dataclass, is_dataclass, asdict
from pathlib import Path

And I don't see a place where dataclasses is referred to as if it was a third-party package.

@diogobaeder
Copy link
Member

Here's a few ideas to look for:

Other than this, I would be happy if we can make sure the package is mypy-strict. For some years I've been trying hard to keep type hints as strict as possible, because they're immensely helpful.

@bswck
Copy link
Member Author

bswck commented Apr 19, 2024

Thanks for assistance. I've been doing such refactors from time to time (CERT-Polska/malduck#111, python-poetry/cleo#365), I'm sure we'll get as much as we can out of it. :)

@bswck
Copy link
Member Author

bswck commented Apr 19, 2024

docs.python.org/3/whatsnew/3.7.html#whatsnew37-pep563 - import future annotations and use where classes reference themselves

I'm very happy you don't oppose to PEP 563. Opinions tend to be pretty controversial.

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

No branches or pull requests

3 participants