Sample

pyint-f820e7995782-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines77

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4630–1; higher is more readable
Mi0.6860–1; higher is more readable
LLOC36Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.3830–1; higher is more readable

Views

Source code

from functools import total_ordering from ._funcs import astuple from ._make import attrib, attrs @total_ordering @attrs(eq=False, order=False, slots=True, frozen=True) class VersionInfo: """ A version object that can be compared to tuple of length 1--4: >>> attr.VersionInfo(19, 1, 0, "final") <= (19, 2) True >>> attr.VersionInfo(19, 1, 0, "final") < (19, 1, 1) True >>> vi = attr.VersionInfo(19, 2, 0, "final") >>> vi < (19, 1, 1) False >>> vi < (19,) False >>> vi == (19, 2,) True >>> vi == (19, 2, 1) False .. versionadded:: 19.2 """ year = attrib(type=int) minor = attrib(type=int) micro = attrib(type=int) releaselevel = attrib(type=str) @classmethod def _from_version_string(cls, s): """ Parse *s* and return a _VersionInfo. """ v = s.split(".") if len(v) == 3: v.append("final") return cls( year=int(v[0]), minor=int(v[1]), micro=int(v[2]), releaselevel=v[3] ) def _ensure_tuple(self, other): """ Ensure *other* is a tuple of a valid length. Returns a possibly transformed *other* and ourselves as a tuple of the same length as *other*. """ if self.__class__ is other.__class__: other = astuple(other) if not isinstance(other, tuple): raise NotImplementedError if not (1 <= len(other) <= 4): raise NotImplementedError return astuple(self)[: len(other)], other def __eq__(self, other): try: us, them = self._ensure_tuple(other) except NotImplementedError: return NotImplemented return us == them def __lt__(self, other): try: us, them = self._ensure_tuple(other) except NotImplementedError: return NotImplemented # Since alphabetically "dev0" < "final" < "post1" < "post2", we don't # have to do anything special with releaselevel for now. return us < them def __hash__(self): return hash((self.year, self.minor, self.micro, self.releaselevel))

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.1843.139−60.824
Source linesThe number of non-empty source lines.77+30.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.463−6.695

Intercept 8.87 + feature contributions = -27.848 (log-odds).
Score = sigmoid(-27.848) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.78−1.725
Indentation frequencyHow rapidly indentation changes from line to line.51+1.027
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.98.987+0.793
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.51−0.749
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.76.88+0.665
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.98.974−0.527
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.066+0.299

Intercept 0.07 + feature contributions = -0.149 (log-odds).
Score = sigmoid(-0.149) = 0.463.

Score0.686
Score36
Run 1

The code is well-structured with clear class definition, logical method grouping, and appropriate use of decorators. Nesting is minimal, primarily limited to validation logic in `_ensure_tuple`. Intent is clear due to descriptive method names and docstrings with examples. Code length is appropriately concise for its purpose. Action granularity is mostly one action per line, though `_from_version_string` has a multi-argument return call that could be slightly reformatted. Reading flow is natural—methods are ordered logically (helper/parse, validation, comparison, hash). Minor readability improvements could include splitting the `return cls(...)` in `_from_version_string` into more readable lines and moving validation checks into separate private methods if expanded further. Overall, this is highly readable production-quality code.

Run 2

The code is generally well-structured and readable. The class has a clear purpose with good documentation and examples. The methods are short and focused with a single responsibility. Nesting is mostly flat with only two levels in methods. Action granularity is reasonable, mostly one action per line. The _ensure_tuple method clearly separates validation and transformation. The use of the total_ordering decorator and attrs is shown clearly. Minor issues: the _from_version_string's return statement is oddly formatted with excessive indentation, and the example docstring could be long in context but serves as useful documentation. Overall, the code is clear and maintains logical flow.

Run 3

The code is well-structured and highly readable. It uses clear naming conventions, logical organization, and a flat hierarchy with minimal nesting. The class is decorated appropriately, with attributes defined using the attrs library for clarity. Each method has a single responsibility and is concise, with docstrings explaining intent. The action granularity is mostly one action per line, though the return statement in `_from_version_string` is slightly compressed but still readable. The reading flow is natural, with helper methods placed after constructors and before comparison methods. The use of `_ensure_tuple` centralizes validation, reducing repetition and improving clarity. Overall, the code is easy to follow and maintain, with only minor formatting choices (like the multi-line return) detracting slightly from perfection.

Run 1

Code Structure: The class is logically organized into fields, parsing, comparison normalization, comparison methods, and hashing, with shared logic extracted into a helper. Nesting: Shallow conditionals and simple try/except blocks keep complexity low. Clarity of intent: Descriptive method names, docstrings, examples, and the release-level comment explain behavior well; abbreviated variables and exception-based signaling slightly reduce clarity. Code length: Concise overall, with useful documentation and little unnecessary implementation. Action granularity: Most lines perform one action, although the constructor call compresses several field conversions onto one long line. Reading flow: Methods follow a natural progression, but missing blank lines between some sections and awkward constructor formatting interrupt readability.

Run 2

Code Structure: Well-organized class with focused parsing, normalization, comparison, and hashing methods; shared comparison logic avoids duplication. Nesting: Shallow conditionals and simple try/except blocks are easy to follow. Clarity of intent: Descriptive method names, docstrings, examples, and a release-order comment explain behavior well, though short names such as s, v, us, and them are less explicit. Code length: Concise implementation with useful documentation rather than unnecessary complexity. Action granularity: Most lines perform one action, but the constructor call compresses several field conversions onto an awkwardly formatted line. Reading flow: Methods follow a logical progression, but missing blank lines between some class members and inconsistent constructor formatting interrupt readability. Decorator-generated behavior and exception-based signaling require some familiarity with Python conventions.

Run 3

Code Structure: The class is logically organized, with parsing, tuple normalization, comparison, and hashing separated into focused methods. Nesting: Shallow conditionals and simple try/except blocks keep complexity low. Clarity of intent: Descriptive method names, docstrings, examples, and the release-level comment explain behavior well, though abbreviated variables and exception-based signaling slightly obscure intent. Code length: Concise overall; comparison methods repeat a small amount of necessary logic. Action granularity: Most lines perform one action, but the constructor call compresses several arguments into an awkwardly formatted line. Reading flow: Methods follow a natural progression, but missing blank lines between some class elements and inconsistent constructor formatting interrupt visual flow.