Skip to content

[Adjust Rule] SIM119 - Use a dataclass rule #63

@Kub-AT

Description

@Kub-AT

Desired change

  • Rule(s): SIM119
  • Adjustment: SIM119 should be more precise.

Explanation

Examples below are suggested as dataclass. I think they shouldnt

Example

class RegexAssert:
    def __init__(self, pattern, flags=0):
        self._regex = re.compile(pattern, flags)

    def __eq__(self, actual):
        return bool(self._regex.match(actual))

    def __repr__(self):
        return self._regex.pattern
class OfType:
    """
    >>> 3 == OfType(int, str, bool)
    True
    >>> 'txt' == OfType(int)
    False
    """

    def __init__(self, *types):
        self.type = types

    def __eq__(self, other):
        return isinstance(other, self.type)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions