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

Modernising type annotations, and Python2 is support #4649

Open
MarcoGorelli opened this issue Feb 1, 2025 · 2 comments · May be fixed by #4650
Open

Modernising type annotations, and Python2 is support #4649

MarcoGorelli opened this issue Feb 1, 2025 · 2 comments · May be fixed by #4650

Comments

@MarcoGorelli
Copy link

The contributing guide says that Python2 is supported:

scapy/CONTRIBUTING.md

Lines 140 to 142 in 42115bf

### Python 2 and 3 compatibility
The project aims to provide code that works both on Python 2 and Python 3. Therefore, some rules need to be applied to achieve compatibility:

However, pyproject.toml lists Python3.7 as the minimum version:

scapy/pyproject.toml

Lines 30 to 38 in a5dab9e

"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",

Is that section of the contributing guide outdated?

If so, would you be open to some pull requests to modernise typing? I've noticed that a large part of the codebase uses Python2 type comments, but for Python3+ projects they're discouraged (for examples, PEP 526 states "As variable annotations are more readable than type comments, they are preferred in stub files for all versions of Python, including Python 2.7")

Some well-tested tools can help with this:

and then some minor manual fixups can get the checks passing. I tried this out in #4650, and it wasn't too much effort, and I verified that tox -e mypy and ./test/run_tests still pass. Would you be interested in modernising type annotations across the codebase?

If there's interest, I'd be happy to do this for the rest of the codebases (for context, I'm part of an effort to improve typing in widely used packages, and there's a lot of interest in Scapy in particular)

@MarcoGorelli MarcoGorelli linked a pull request Feb 1, 2025 that will close this issue
5 tasks
@gpotter2
Copy link
Member

gpotter2 commented Feb 1, 2025

Hi, you're right the guide is outdated.
Regarding an upgrade, we're a bit careful when it comes to large commits that break history.
I think we need to discuss this first with other maintainers to think about what we would prefer.

Thanks for bringing this up

@MarcoGorelli
Copy link
Author

Thanks for your response! Sure, happy to wait for others' thoughts before proceeding

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 a pull request may close this issue.

2 participants