Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MNT]: de-duplicate hatch validation #24797

@story645

Description

@story645

Summary

In#17926 code to validate hatches got added to the hatch module:

def_validate_hatch_pattern(hatch):
valid_hatch_patterns=set(r'-+|/\xXoO.*')
ifhatchisnotNone:
invalids=set(hatch).difference(valid_hatch_patterns)
ifinvalids:
valid=''.join(sorted(valid_hatch_patterns))
invalids=''.join(sorted(invalids))
_api.warn_deprecated(
'3.4',
removal='3.8',# one release after custom hatches (#20690)
message=f'hatch must consist of a string of "{valid}" or '
'None, but found the following invalid values '
f'"{invalids}". Passing invalid values is deprecated '
'since %(since)s and will become an error %(removal)s.'
)

and there's near identical code in rc validation that went in in#4686:

defvalidate_hatch(s):
r"""
Validate a hatch pattern.
A hatch pattern string can have any sequence of the following
characters: ``\ / | - + * . x o O``.
"""
ifnotisinstance(s,str):
raiseValueError("Hatch pattern must be a string")
_api.check_isinstance(str,hatch_pattern=s)
unknown=set(s)- {'\\','/','|','-','+','*','.','x','o','O'}
ifunknown:
raiseValueError("Unknown hatch symbol(s): %s"%list(unknown))
returns

They diverge slightly in that the hatch version has a deprecation warning but I think it should also apply to the rc version?

Proposed fix

Make the validation function in hatch.py the canonical validator and either deprecate the rcsetup validation function or turn it into a thin shim over the one in hatch.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp