Sample

pyint-95110e6ebfc5-I01

Remove comments and docstrings

Matched original source

Lines152

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8450–1; higher is more readable
Mi0.6060–1; higher is more readable
LLOC91Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.3570–1; higher is more readable

Views

Source code

from __future__ import annotations import errno import json import os import types import typing as t from werkzeug.utils import import_string class Config(dict): def __init__( self, root_path: str | os.PathLike[str], defaults: dict[str, t.Any] | None = None, ) -> None: super().__init__(defaults or {}) self.root_path = root_path def from_envvar(self, variable_name: str, silent: bool = False) -> bool: rv = os.environ.get(variable_name) if not rv: if silent: return False raise RuntimeError( f"The environment variable {variable_name!r} is not set" " and as such configuration could not be loaded. Set" " this variable and make it point to a configuration" " file" ) return self.from_pyfile(rv, silent=silent) def from_prefixed_env( self, prefix: str = "FLASK", *, loads: t.Callable[[str], t.Any] = json.loads ) -> bool: prefix = f"{prefix}_" for key in sorted(os.environ): if not key.startswith(prefix): continue value = os.environ[key] key = key.removeprefix(prefix) try: value = loads(value) except Exception: pass if "__" not in key: self[key] = value continue current = self *parts, tail = key.split("__") for part in parts: if part not in current: current[part] = {} current = current[part] current[tail] = value return True def from_pyfile( self, filename: str | os.PathLike[str], silent: bool = False ) -> bool: filename = os.path.join(self.root_path, filename) d = types.ModuleType("config") d.__file__ = filename try: with open(filename, mode="rb") as config_file: exec(compile(config_file.read(), filename, "exec"), d.__dict__) except OSError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR, errno.ENOTDIR): return False e.strerror = f"Unable to load configuration file ({e.strerror})" raise self.from_object(d) return True def from_object(self, obj: object | str) -> None: if isinstance(obj, str): obj = import_string(obj) for key in dir(obj): if key.isupper(): self[key] = getattr(obj, key) def from_file( self, filename: str | os.PathLike[str], load: t.Callable[[t.IO[t.Any]], t.Mapping[str, t.Any]], silent: bool = False, text: bool = True, ) -> bool: filename = os.path.join(self.root_path, filename) try: with open(filename, "r" if text else "rb") as f: obj = load(f) except OSError as e: if silent and e.errno in (errno.ENOENT, errno.EISDIR): return False e.strerror = f"Unable to load configuration file ({e.strerror})" raise return self.from_mapping(obj) def from_mapping( self, mapping: t.Mapping[str, t.Any] | None = None, **kwargs: t.Any ) -> bool: mappings: dict[str, t.Any] = {} if mapping is not None: mappings.update(mapping) mappings.update(kwargs) for key, value in mappings.items(): if key.isupper(): self[key] = value return True def get_namespace( self, namespace: str, lowercase: bool = True, trim_namespace: bool = True ) -> dict[str, t.Any]: rv = {} for k, v in self.items(): if not k.startswith(namespace): continue if trim_namespace: key = k[len(namespace) :] else: key = k if lowercase: key = key.lower() rv[key] = v return rv def __repr__(self) -> str: return f"<{type(self).__name__} {dict.__repr__(self)}>"

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.5619.701−185.45
Source linesThe number of non-empty source lines.152+60.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.141−6.212

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.152+4.52
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.153−4.381
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.151.729+1.711
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.83.915+0.111
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.089+0.074

Intercept 0.07 + feature contributions = 1.699 (log-odds).
Score = sigmoid(1.699) = 0.845.

Score0.606
Score91
Run 1

The Config class is well-structured and readable. Each method has a single clear purpose, with flat nesting and concise logic. Type hints and docstring-like comments improve clarity. Minor issues: some sections rely on trailing comments (e.g., after try/except) that are slightly terse; error-handling repetition adds minor length but is acceptable. Overall, strong organization, natural reading flow, and clear intent make this highly readable.

Run 2

The code is highly readable with clear structure, minimal nesting, and explicit intent. Each method has a single responsibility and is logically organized. Nesting is shallow, with early returns and clear error handling. The code is concise but not overly compressed; each action is on its own line, promoting readability. Naming is descriptive, and type hints improve understandability. Comments are minimal but sufficient—section headers and inline explanations clarify complex parts without redundancy. The reading flow is natural, with helper methods ordered logically by functionality. Minor improvements could include more detailed docstrings for complex methods like from_prefixed_env, but overall the code is clean, maintainable, and easy to follow.

Run 3

The code is well-structured and readable. It uses clear method names, type hints, and consistent formatting. Nesting is minimal, with early returns and guard clauses improving flow. The logic for nested dict creation in from_prefixed_env is somewhat complex but well-commented. Code length is appropriate for the functionality, and each method has a single responsibility. Action granularity is generally one action per line, though some lines combine string formatting and assignment. Reading flow is natural, with related methods grouped. Minor deductions: some methods like from_object and from_prefixed_env have dense nested operations that require careful reading; placeholder comments are empty; and a few error-handling expressions mix logic and string construction. Overall, this is clean, maintainable configuration-handling code.

Run 1

Code Structure: Well-organized class with distinct methods for each configuration source and namespace extraction. Nesting: Generally shallow; nested environment-variable processing is the most complex section, but early continues keep it manageable. Clarity of intent: Descriptive method names and type annotations communicate purpose, though abbreviated variables such as rv, d, k, and v and missing docstrings obscure some details. Code length: Methods are concise overall, with modest duplication in file-loading error handling and unnecessary blank lines. Action granularity: Most lines perform one clear action; the combined read, compile, and exec expression is denser than the surrounding code. Reading flow: Consistent method patterns and straightforward control flow make the code easy to follow, although irregular whitespace and unexplained parsing fallback slightly interrupt comprehension.

Run 2

Code Structure: Well-organized class with focused methods for distinct configuration sources and namespace extraction. Nesting: Mostly shallow, with early returns and continue statements limiting indentation; nested environment-key handling is slightly more involved. Clarity of intent: Descriptive method names and type annotations communicate purpose, but absent docstrings, abbreviated variables such as rv and d, and unexplained broad exception suppression obscure some behavior. Code length: Methods are reasonably concise, though repeated file-loading error handling and excessive blank lines add minor clutter. Action granularity: Most lines perform one action; the combined read, compile, and exec expression is comparatively dense. Reading flow: Consistent method patterns and straightforward control flow make the class easy to follow, with minor interruptions from whitespace and undocumented conventions such as uppercase-only keys and double-underscore nesting.

Run 3

Code Structure: Well organized into focused methods for loading and filtering configuration, with minor duplication in file-error handling. Nesting: Mostly shallow; environment parsing has moderate nesting but uses early continuation effectively. Clarity of intent: Descriptive method names and type annotations make the purpose clear, though abbreviated variables (rv, d, k, v), missing docstrings, and unexplained double-underscore nesting conventions reduce clarity. Code length: Methods are concise and appropriately sized, but excessive blank lines add visual noise. Action granularity: Most lines perform one action; the combined read/compile/exec expression is denser than surrounding code. Reading flow: Generally natural and sequential, with consistent patterns across loaders; silent exception handling and dynamic execution require extra interpretation.