Skip to content

Remove unnecessary quotes in type annotations - #44

Merged
timrid merged 1 commit into
mainfrom
remove-unnecessary-quotes
Jul 27, 2026
Merged

Remove unnecessary quotes in type annotations#44
timrid merged 1 commit into
mainfrom
remove-unnecessary-quotes

Conversation

@timrid

@timrid timrid commented Jul 27, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the codebase’s type annotations by enabling Ruff’s pyupgrade rule for unnecessary quoted annotations and then updating modules accordingly (primarily via from __future__ import annotations plus unquoted/PEP 604-style annotations).

Changes:

  • Enable Ruff pyupgrade rule UP037 to flag and autofix unnecessary quoted annotations.
  • Add from __future__ import annotations broadly to allow safe forward references without quotes.
  • Convert quoted/typing.Union/Optional style annotations to modern X | Y / T | None forms and unquote forward references.

Reviewed changes

Copilot reviewed 57 out of 57 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Enable Ruff UP037 to enforce removal of unnecessary quoted annotations.
construct_editor/wx_widgets/wx_python_code_editor.py Add postponed evaluation for annotations to support unquoted forward refs.
construct_editor/wx_widgets/wx_obj_view.py Replace quoted/Union[...] annotations with `
construct_editor/wx_widgets/wx_hex_editor.py Add postponed annotations and remove quoting in callback/type annotations.
construct_editor/wx_widgets/wx_exception_dialog.py Add postponed annotations for consistency with de-quoted hints.
construct_editor/wx_widgets/wx_context_menu.py Add postponed annotations and modernize constructor type hints.
construct_editor/wx_widgets/wx_construct_hex_editor.py Remove quoted forward refs in return/attribute annotations using `
construct_editor/wx_widgets/wx_construct_editor.py Modernize a few annotations (e.g., remove quoted wx types).
construct_editor/main.py Add postponed annotations support (module-wide consistency).
construct_editor/gallery/init.py Add postponed annotations and unquote cs.Construct[...] annotation.
construct_editor/gallery/test_timestamp.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_tflagsenum.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_tenum.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_switch.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_switch_dataclass.py Add postponed annotations and unquote nested-class return type refs.
construct_editor/gallery/test_stringencodded.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_select.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_select_complex.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_renamed.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_pointer_peek_seek_tell.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_pass.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_padded.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_padded_string.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_nullterminated.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_nullstripped.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_ifthenelse.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_ifthenelse_nested_switch.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_greedyrange.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_focusedseq.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_flagsenum.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_flag.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_fixedsized.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_enum.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_default.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_dataclass_struct.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_dataclass_bit_struct.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_const.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_computed.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_compressed.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_checksum.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_bytes_greedybytes.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_bitwise.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_bits_swapped_bitwise.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_array.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/test_aligned.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/example_pe32coff.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/gallery/example_ipstack.py Add postponed annotations after module docstring (valid placement).
construct_editor/gallery/example_cmd_resp.py Add postponed annotations to support unquoted annotations consistently.
construct_editor/core/preprocessor.py Add postponed annotations and unquote/update typed hints (e.g., `GuiMetaData
construct_editor/core/model.py Add postponed annotations and modernize `entries.EntryConstruct
construct_editor/core/entries.py Add postponed annotations; convert many quoted refs to unquoted and modern union syntax.
construct_editor/core/custom.py Add postponed annotations and modernize adapter/subconstruct type hints.
construct_editor/core/context_menu.py Add postponed annotations and de-quote recursive MenuItem references.
construct_editor/core/construct_editor.py Add postponed annotations and modernize callback ParamSpec usage.
construct_editor/core/commands.py Add postponed annotations (module-wide consistency).
construct_editor/core/callbacks.py Add postponed annotations; aligns with ParamSpec-based CallbackList typing usage.
construct_editor/core/init.py Remove now-unnecessary encoding header comment (empty module).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@timrid
timrid merged commit ee4c040 into main Jul 27, 2026
1 check passed
@timrid
timrid deleted the remove-unnecessary-quotes branch July 27, 2026 06:47
import string
import typing as t
from typing import Any, Dict, List, Optional, Type
from typing import Any, Dict, List, Type

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would recommend switching to t.Any etc.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

And let's get rid of Dict and List in favor of dict and list.

@@ -1,3 +1,5 @@
from __future__ import annotations

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like you put this everywhere - even when not (yet) needed?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Exactly. So we don't forget, in case we expand the file later. Only if that's there will Ruff recognize the “” quotes in the type hints as redundant and flag them as such.

@timrid timrid mentioned this pull request Jul 27, 2026
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.

3 participants