Skip to content

Remove custom FormParser classes#257

Merged
Kludex merged 4 commits intomasterfrom
fix-parse-form-callback-types
Apr 10, 2026
Merged

Remove custom FormParser classes#257
Kludex merged 4 commits intomasterfrom
fix-parse-form-callback-types

Conversation

@Kludex
Copy link
Copy Markdown
Owner

@Kludex Kludex commented Apr 10, 2026

Summary

Removes the FileClass and FieldClass parameters from FormParser. The parser now consistently constructs the built-in File and Field classes, and callback annotations are concrete accordingly.

Also updates the coverage configuration to use exclude_also with the reduced exclusion list.

Validation

  • .venv/bin/mypy python_multipart multipart tests
  • .venv/bin/pytest tests/test_multipart.py -q
  • .venv/bin/ruff check python_multipart/multipart.py tests/test_multipart.py
  • .venv/bin/ruff format --check --diff python_multipart/multipart.py tests/test_multipart.py

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e4fe5053e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python_multipart/multipart.py Outdated
Comment on lines +1540 to +1541
FileClass: type[FileT],
FieldClass: type[FieldT],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep custom class overload parameters independently optional

The new generic FormParser.__init__ overload makes both FileClass and FieldClass required together, while the non-generic overload only accepts concrete type[File]/type[Field]. This introduces a typing regression for valid existing usage where only one custom class is provided (for example FileClass=MyFile with the default field class): runtime still supports it via defaults, but static checkers now reject it because no overload matches. Making these parameters independently optional in the generic overload (or adding mixed overloads) would preserve previous behavior.

Useful? React with 👍 / 👎.

@Kludex Kludex changed the title Fix parse_form callback typing Fix callback typing and coverage exclusions Apr 10, 2026
@Kludex Kludex changed the title Fix callback typing and coverage exclusions Remove custom FormParser classes Apr 10, 2026
Comment on lines -1541 to -1543
# Save classes.
self.FileClass = File
self.FieldClass = Field
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.

The whole thing was non-used for 13 years. 👀

@Kludex Kludex merged commit ef2a0b9 into master Apr 10, 2026
12 checks passed
@Kludex Kludex deleted the fix-parse-form-callback-types branch April 10, 2026 10:53
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