Skip to content

chore: add encoding= to open() and type hints in setup.py and utils.py#32

Open
mangodxd wants to merge 1 commit intodanielkaiser:masterfrom
mangodxd:cleanup/fix-py-issues-8e2edce0
Open

chore: add encoding= to open() and type hints in setup.py and utils.py#32
mangodxd wants to merge 1 commit intodanielkaiser:masterfrom
mangodxd:cleanup/fix-py-issues-8e2edce0

Conversation

@mangodxd
Copy link
Copy Markdown

@mangodxd mangodxd commented Apr 5, 2026

Hello,

I noticed a few areas where the code could be made a bit more robust and readable. This PR focuses on minor housekeeping tasks and does not change any of the existing runtime logic:

Explicit encoding for file operations

  • setup.py: added encoding="utf-8" to 1 open() call(s)

I added explicit encoding here because Python's default behavior depends on the operating system. This change ensures the code handles text consistently whether it is running on Windows, Linux, or macOS, preventing potential UnicodeDecodeErrors.

Type hint additions

  • setup.py: added type hints to 1 function(s)
  • utils.py: added type hints to 9 function(s)

I have added basic type annotations based on variable names and default values. This should make the code easier to work with in modern IDEs without changing any of the actual logic.

Examples of changes

Example change in setup.py:

-with open('README.md') as readme_file:
+with open('README.md', encoding="utf-8") as readme_file:
-    def run(self):
+    def run(self) -> None:

Example change in utils.py:

-def get_chromedriver_filename():
+def get_chromedriver_filename() -> str:
-def get_variable_separator():
+def get_variable_separator() -> str:
-def get_legacy_chromedriver_url(version):
+def get_legacy_chromedriver_url(version: int):
-def get_chromedriver_url(version):
+def get_chromedriver_url(version: int):
-def find_binary_in_path(filename):
+def find_binary_in_path(filename: str) -> None:
-def get_latest_legacy_release_for_version(version):
+def get_latest_legacy_release_for_version(version: int):
... (truncated for brevity)

Safety and verification

  • I verified these changes using ast.parse() to ensure no syntax errors were introduced.
  • Files using dynamic patterns like eval() or globals() were automatically skipped.
  • I did not modify any __init__.py files.

Let me know if you would like me to change anything here.

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.

1 participant