Skip to content

Explain the casing/substring matching of Enums on help-msgs and errors#426

Merged
minrk merged 2 commits intoipython:masterfrom
ankostis:enumhelp
Aug 8, 2017
Merged

Explain the casing/substring matching of Enums on help-msgs and errors#426
minrk merged 2 commits intoipython:masterfrom
ankostis:enumhelp

Conversation

@ankostis
Copy link
Contributor

@ankostis ankostis commented Jul 5, 2017

From the help-messages, config-file headers and invalid-value error-messages on FuzzyEnum it's impossible to know whether it is case-sensitive and matches substrings or prefixes.
That was problematic also because allow_none information was simply omitted.

Changes:

  • Help and Config messages reuse Enum.info() instead of Enum.values (as Trait.error(0 does).
  • Enhanced CaselessStrEnum.info().
  • Changes possibly(?) relevant also for Better Errors for Nested Traits #402.

Sample output:

  • Before:

    refact(help): reuse `Enum.info()` 
    
    --TstampSender.send_transfer_encoding=<FuzzyEnum>
        Set the Content-Transfer-Encoding MIME Header and encodes appropriately
        outgoing mails.
        Choices: ['BASE64', 'QUOPRI', '7OR8BIT', 'base64', 'quopri', '7or8bit', 'noenc']
        Default: None
    
  • AFTER:

    --TstampSender.send_transfer_encoding=<FuzzyEnum>
        Set the Content-Transfer-Encoding MIME Header and encodes appropriately
        outgoing mails.
        Choices: any case-sensitive prefix of ['BASE64', 'QUOPRI', '7OR8BIT', 'base64', 'quopri', '7or8bit', 'noenc'] or None
        Default: None
    

@ankostis
Copy link
Contributor Author

ankostis commented Jul 5, 2017

I think also class_config_rst_doc() does not report if none_allowed.

+ Add Py3-only Caseless/FuzzyEnum TC for help and config messages.
@minrk minrk merged commit 8492689 into ipython:master Aug 8, 2017
@Carreau Carreau added this to the 5.0 milestone Jun 4, 2020
@Carreau Carreau added 5.0-re-review Need to re-review for potential API impact changes. 5.0-minor rereviewed, minor change need to be put in changelog. labels Jun 4, 2020
@Carreau Carreau added 5.0-no-incidence change that has noincidence on 5.0 compat (eg: doc) and removed 5.0-minor rereviewed, minor change need to be put in changelog. 5.0-re-review Need to re-review for potential API impact changes. labels Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.0-no-incidence change that has noincidence on 5.0 compat (eg: doc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants