<commit_before>##
# See the file COPYRIGHT for copyright information.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

"""
Address
"""

from abc import ABC
from typing import Optional

from attr import attrib, attrs
from attr.validators import instance_of, optional

Optional  # Silence linter


__all__ = ()



class Address(ABC):
    """
    Location address
    """

    description: str



@attrs(frozen=True)
class TextOnlyAddress(Address):
    """
    Address

    An address contains a description of a location.
    """

    description = attrib(validator=instance_of(str))  # type: str



@attrs(frozen=True)
class RodGarettAddress(Address):
    """
    Rod Garett Address

    Address at concentric and radial streets, as per Rod Garett's design for
    Black Rock City.
    """

    concentric = attrib(
        validator=optional(instance_of(int))
    )  # type: Optional[int]
    radialHour = attrib(
        validator=optional(instance_of(int))
    )  # type: Optional[int]
    radialMinute = attrib(
        validator=optional(instance_of(int))
    )  # type: Optional[int]
    description = attrib(
        validator=instance_of(str)
    )  # type: str<commit_msg>Allow comparing a RodGarettAddress with a TextOnlyAddress if the address fields are None.<commit_after>##
# See the file COPYRIGHT for copyright information.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

"""
Address
"""

from abc import ABC
from typing import Any, Optional

from attr import attrib, attrs
from attr.validators import instance_of, optional

Optional  # Silence linter


__all__ = ()



class Address(ABC):
    """
    Location address
    """

    description: str



@attrs(frozen=True)
class TextOnlyAddress(Address):
    """
    Address

    An address contains a description of a location.
    """

    description = attrib(validator=instance_of(str))  # type: str



@attrs(frozen=True, cmp=False)
class RodGarettAddress(Address):
    """
    <NAME> Address

    Address at concentric and radial streets, as per <NAME>'s design for
    Black Rock City.
    """

    description = attrib(
        validator=instance_of(str)
    )  # type: str
    concentric = attrib(
        validator=optional(instance_of(int)), default=None
    )  # type: Optional[int]
    radialHour = attrib(
        validator=optional(instance_of(int)), default=None
    )  # type: Optional[int]
    radialMinute = attrib(
        validator=optional(instance_of(int)), default=None
    )  # type: Optional[int]


    def _cmpValue(self) -> Any:
        return (
            self.concentric, self.radialHour, self.radialMinute,
            self.description,
        )


    def _cmp(self, other: Any, methodName: str) -> bool:
        if other.__class__ is self.__class__:
            selfValue = self._cmpValue()
            otherValue = other._cmpValue()
            selfValueCmp = getattr(selfValue, methodName)
            return selfValueCmp(otherValue)

        if other.__class__ is TextOnlyAddress:
            if (
                self.concentric is None and
                self.radialHour is None and
                self.radialMinute is None
            ):
                return getattr(self.description, methodName)(other.description)

        return NotImplemented


    def __eq__(self, other: Any) -> bool:
        return self._cmp(other, "__eq__")


    def __ne__(self, other: Any) -> bool:
        return self._cmp(other, "__ne__")


    def __lt__(self, other: Any) -> bool:
        return self._cmp(other, "__lt__")


    def __le__(self, other: Any) -> bool:
        return self._cmp(other, "__le__")


    def __gt__(self, other: Any) -> bool:
        return self._cmp(other, "__gt__")


    def __ge__(self, other: Any) -> bool:
        return self._cmp(other, "__ge__")
{'fraction_non_alphanumeric': 0.09388097233864208, 'fraction_numerical': 0.0016764459346186086, 'mean_word_length': 2.9544324772162387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1520796', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1352, 'n_words': 455}