Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

Continues typing work from PR #223 (dmarc.py) by converting all dict() constructor calls to literal dictionaries and fixing TypedDict definitions across remaining modules to enable proper type checking.

Changes

Dictionary constructor conversions (~60 instances)

  • dict(){}
  • dict(key=value){"key": value}
  • dict([("key", value)]){"key": value}
  • Nested constant structures (BIMI_TAGS, mta_sts_tags, smtp_rpt_tags)

TypedDict fixes and cast removal

  • Fixed SMTPTLSReportingTags: was single value TypedDict, now dict[str, SMTPTLSReportingTagValue]
  • Fixed MTASTSTags: was single value TypedDict, now dict[str, str]
  • Fixed ParsedMTASTSPolicy: field name "v" → "version" to match implementation
  • Removed 5 cast() calls by properly typing dictionary construction

Type refinement

  • check_mta_sts: dict[str, Any]MTASTSCheckResults (Union of success/failure TypedDicts)
  • Proper initialization of TypedDict-typed variables instead of dynamic dict building
# Before
mta_sts_results = dict([("valid", True)])
mta_sts_results["id"] = ...
mta_sts_results["policy"] = ...

# After
mta_sts_results: MTASTSCheckSuccess = {
    "valid": True,
    "id": id_value,
    "policy": policy["policy"],
    "warnings": warnings,
}

Python 3.9 compatibility

  • Union[] syntax (no pipe unions)
  • dict[str, ...] type aliases per PEP 585 (matches dmarc.py pattern)
  • No NotRequired usage
Original prompt

Continue the work of this PR that added explcit dmarc.py typing to all of the other moduls in checkdmarc. First, convert any use of dict() or OrderedDict() to a literal dictionary so that typing can work correctly. You must avoid any uses of casting or any, and prefer typedicts instead. The code must be compatible with python 3.9 and up. Keep code changes as simple and minimal as posible to complete the typing task without causing drift and possibly introducing new bugs. The code must pass pylance and ruff checks. Doo not use syntax that cannot be used in Python 3.9, such as NotRequired or pipe unions.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits December 19, 2025 19:07
Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com>
Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com>
Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com>
Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor dict usage to typed dicts for compatibility Convert dict() calls to literals and improve typing with TypedDicts Dec 19, 2025
Copilot AI requested a review from seanthegeek December 19, 2025 19:30
@seanthegeek
Copy link
Contributor

@copilot Run tests.py and make sure al tests pass

Copy link
Contributor Author

Copilot AI commented Dec 19, 2025

@copilot Run tests.py and make sure al tests pass

All tests pass ✓ (29 tests run, 2 skipped, 0 failures)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • vmc.digicert.com
    • Triggering command: /usr/bin/python python tests.py (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@seanthegeek seanthegeek marked this pull request as ready for review December 19, 2025 19:42
@seanthegeek seanthegeek merged commit 8172645 into main Dec 19, 2025
2 checks passed
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