Skip to content

chore: modernize type hints to PEP 604 union syntax#38

Merged
masterking32 merged 6 commits intomasterking32:mainfrom
tboy1337:chore/modernize-type-hints
Mar 16, 2026
Merged

chore: modernize type hints to PEP 604 union syntax#38
masterking32 merged 6 commits intomasterking32:mainfrom
tboy1337:chore/modernize-type-hints

Conversation

@tboy1337
Copy link
Contributor

Summary

  • Remove Optional, Dict, and Tuple imports from typing module across all affected source files
  • Replace with PEP 604 union syntax (X | None) and PEP 585 built-in generics (dict[K,V], tuple[...]) available since Python 3.10
  • Add # pylint: disable=import-outside-toplevel on intentional platform-specific inline imports (uvloop, ctypes.wintypes)

Files changed

  • client.py - 6 annotation updates, remove Optional/Tuple imports
  • server.py - 8 annotation updates, remove Optional import
  • dns_utils/DnsPacketParser.py - Any | None annotation, remove Optional import
  • dns_utils/utils.py - str | None return type, remove Optional import

Notes

dns_utils/ARQ.py type hint modernization is included in the companion PR ix/arq-io-loop alongside the ARQ IO loop bug fixes to keep that diff self-contained.

Replace Optional[X], Dict[K,V], and Tuple[X,Y] from the typing module
with the built-in PEP 604 / PEP 585 equivalents (X | None, dict[K,V],
tuple[X,Y]) across client.py, server.py, DnsPacketParser.py, and
utils.py. Also adds pylint disable comments for the intentional
import-outside-toplevel patterns on platform-specific inline imports.

Made-with: Cursor
Added a requirement for Python version 3.10 or higher in the setup configuration to ensure compatibility with the codebase.
@tboy1337 tboy1337 changed the title Chore/modernize type hints chore: modernize type hints to PEP 604 union syntax Mar 13, 2026
Preserve both name='dns_utils_cython_build' from main and
python_requires='>=3.10' from the PR branch.

Made-with: Cursor
Resolve three merge conflicts from upstream divergence:

- build_setup.py: adopt upstream name 'masterdnsvpn_cython_build' while
  retaining python_requires='>=3.10' constraint.
- client.py: keep PEP 604 typed signature for _process_received_packet;
  modernize two Optional usages added by upstream to X | None syntax.
- server.py: drop unused typing imports; modernize all Optional[X]
  annotations added by upstream to X | None syntax; include upstream's
  new _pre_session_packet_types early-exit block in handle_vpn_packet.

Made-with: Cursor
@masterking32 masterking32 merged commit 97c4756 into masterking32:main Mar 16, 2026
masterking32 added a commit that referenced this pull request Mar 16, 2026
masterking32 added a commit that referenced this pull request Mar 16, 2026
@tboy1337
Copy link
Contributor Author

@masterking32 I think #40 was needed first because of the pyproject.toml.

@masterking32
Copy link
Owner

These changes are not acceptable because they do not support older Python versions!

@tboy1337
Copy link
Contributor Author

tboy1337 commented Mar 17, 2026

These changes are not acceptable because they do not support older Python versions!

Python 3.9 is now fully end of life and stopped receiving security updates on 31 Oct 2025, these changes are supported by Python 3.10+.

https://devguide.python.org/versions

@masterking32
Copy link
Owner

Yeah, that's true, but Ubuntu 20.04 comes with Python 3.8 and some other versions of Linux.
People are still using old OS versions.

@tboy1337
Copy link
Contributor Author

tboy1337 commented Mar 17, 2026

Yeah, that's true, but Ubuntu 20.04 comes with Python 3.8 and some other versions of Linux. People are still using old OS versions.

What should the minimum supported version be? 3.8? It could be an option to advise users of outdated python versions to use https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa to update to a newer version while still staying on the same os version.

There are several high security vulnerabilities in 3.8-3.9.

@masterking32
Copy link
Owner

Never mind, I need to switch to Go-Lang, Python is not good for this project xD

@tboy1337
Copy link
Contributor Author

Never mind, I need to switch to Go-Lang, Python is not good for this project xD

Claude can rewrite it, I would do it but im using too many tokens.

@masterking32
Copy link
Owner

masterking32 commented Mar 18, 2026

Never mind, I need to switch to Go-Lang, Python is not good for this project xD

Claude can rewrite it, I would do it but im using too many tokens.

That's cool, but I've already started that,
https://github.com/masterking32/MasterDnsVPN/tree/Golang
Please wait for the merge #52, then try to find bugs in networks with +80% loss, and resolve time 0.5-10 sec, and then focus on CPU usage.

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