Uh oh!
There was an error while loading. Please reload this page.
gh-102542 Refactor the mime audio module - #102540
Conversation
e60185c to
44c5f8cCompare| _subtype = _what(_audiodata) | ||
| if _subtype is None: | ||
| raise TypeError('Could not find audio MIME subtype') | ||
| _subtype = _subtype or _infer_subtype(_audiodata) |
There was a problem hiding this comment.
This changes the behavior if _subtype is '' (or any other non-None null value). Someone other than me needs to agree with this.
There was a problem hiding this comment.
That's correct. Falsey values other than None such as: 0, False, '' and empty collections will all fall back to the second or operand: _infer_subtype(_audiodata).
There was a problem hiding this comment.
I personally prefer more explicit tests than just "falseiness" when a more explicit type is indicated. In this case _subtype=None defaults to None to mean that this argument wasn't given.
terryjreedy
commented
Mar 8, 2023
@warsaw This PR mostly replaces the section you committed April '22. I believe that replacement logic is correct. Joseph, have you checked the coverage of the mime audio test? |
JosephSBoyle
commented
Mar 9, 2023
None of the tests execute this path as far as I could tell from putting a breakpoint in and running the tests. I convinced myself that the logic in |
e3f62eb to
09cd7f1CompareJosephSBoyle
commented
Mar 9, 2023
Force pushed to correct a mistake in the commit message. |
AlexWaygood
commented
Mar 9, 2023
That implies that we should perhaps first work on improving test coverage, before undertaking a risky refactoring of this module. ("Risky" only in the sense that all refactorings are risky if test coverage is low :) |
ac8e652 to
5b26332CompareJosephSBoyle
commented
Mar 9, 2023
You're right as usual;) Turns out adding the tests was easier than I first thought. Apologies for rebasing rather than merging, I'm still working on using that workflow @AlexWaygood |
JosephSBoyle
commented
Mar 11, 2023
Update: I was incorrect about this path not being tested - there are in fact tests for this, see: As such I've deleted the redundant ones. |
JosephSBoyle
commented
May 23, 2023
@terryjreedy could you have a re-review when you get a chance please. I think the minimum set of changes for this PR would be simply removing the unused |
terryjreedy
left a comment
There was a problem hiding this comment.
I have nothing to add, which was that I will not approve the change as this is outside my expertise.
JosephSBoyle
commented
May 24, 2023
Hia @AlexWaygood. Who I should request a review from on this? I have the feeling it may have slipped through people's todos! Cheers |
warsaw
commented
Jul 3, 2023
I've provided some additional thoughts on #102542 |
JosephSBoyle
commented
Jul 4, 2023
Closing as we've decided to leave the |
Refactor the MIME audio module, the mechanism for attempting to infer a subtype is currently quite verbose.
Notes:
fakefileis not used in any of the functions it is passed to, hence it has been removed.hrd = data[:512]) isn't necessary so has been removed.