Repository navigation
fix(const): make Command.get reject a non-str key as Method.get does (#1824) - #1826
Merged
Merged
Conversation
…1824) Command.get was a staticmethod that called key.upper() on any key, so a bytes key returned an unregistered member keyed by the bytes object and an int key raised a builtin AttributeError, ignoring default. - The vendor template's get is now a classmethod that hands a non-str key to EnumLookup.get, whose _validate_value call raises EnumValueError. default is not forwarded there, as Method.get forwards none, so a refused key raises with or without one. A str key keeps the case-insensitive lookup and the unregistered-member fallback unchanged. - pcapkit/const/ftp/command.py is re-rendered offline from the template; only get and its docstring change, plus _validate_value's docstring, which now says get reaches it too. - registry-protocol.rst no longer lists Command.get as a surviving staticmethod, and the tests that pinned that shape follow. - A new test pins bytes, int, int-with-default and the str cases, and fails on main. Closes #1824
Owner
Author
|
Verdict: GOOD TO GO at
|
Contributor
|
Coverage: 90.05% (unit tier, Python 3.15,
Per-file detail: the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (
make pylint,make mypy,make isort)make testpasses, and a test case covers the change. Narrow runs only, listed below.Added a changelog entry under
docs/source/changelog/and regeneratedCHANGELOG.md, if the change is user-visible: N/A — centralised in docs(changelog): shared 1.5.0 changelog — long-lived, merges last (#610, #616, #617, #618, #620) #657What is the purpose of your pull request?
Tick the commit type your subject line carries.
fix— corrects a defectfeat— adds a featureperf— changes performance, not behaviourrefactor— changes neither behaviour nor performancetest— tests onlydocs— documentation onlyci— workflows or build toolingrelease— bumps the version or rolls up a distributionchore— anything elseDescription
Closes #1824.
Command.getwas astaticmethodthat calledkey.upper()on any key:get(b'\x01')minted a member keyed by bytes;get(-1)raised a builtinAttributeErrorand ignoreddefault.It now follows
Method.get(#908). It is aclassmethod, and a non-strkey goes toEnumLookup.get, whose_validate_value(from #1823) raisesEnumValueError. MirroringMethod.get,defaultdoes not rescue a refused key: this override'sdefaultis the value of the unregistered member it builds, not a registered fallback.A
strkey behaves exactly as before: a case-insensitive lookup, with the unregistered-member fallback in the caller's casing.pcapkit/vendor/ftp/command.py, and the const file was regenerated offline. An AST check againstmainshows that onlyCommand.getand the_validate_valuedocstring changed, and no member data.FEATCode.getwas already correct... versionchanged:: 1.5.0onCommand.get.registry-protocol.rstandtest_conventions_doc_claims.pyno longer list it as astaticmethod.tests/const/test_const_ftp_command_get_key_type_1824_unit.pycovers each key type, a key paired with a default, case handling and parity withMethod.get. It fails 9 times onmain.tests/const(355 passed) andtests/project(959 passed, 1 skipped) pass.