Przeglądaj źródła

Inline the single-purpose asset_id local; codify when locals earn their line

A local that only re-aliases a non-optional typed attribute adds a name
without meaning. The rule goes under 'Names that say what they mean',
framed as meaning-not-lines so it sits beside today's line-count rule
without contradicting it.
Paul Klumpp 1 tydzień temu
rodzic
commit
83d2330ba2
2 zmienionych plików z 6 dodań i 4 usunięć
  1. 4 1
      AGENTS.md
  2. 2 3
      adapter.py

+ 4 - 1
AGENTS.md

@@ -162,7 +162,10 @@ guidelines. Optimising for that reader is not optional polish. Concretely:
   commentary to explain its flow, split it until the code explains itself.
 - **Names that say what they mean.** `_seed_room` beats `do_init`; a boolean
   reads as a question (`is_seen`, `retryable`). No single-letter names outside
-  throwaway loop variables.
+  throwaway loop variables. Locals earn their line the same way: keep them
+  when they narrow, transform or get reused across branches; drop them when
+  they only re-alias a typed attribute (`asset_id = asset.id` reads inline
+  just as well).
 - **Comments explain why, not what.** The code already says what happens;
   the comment earns its line by recording intent, constraints, or the bug a
   guard exists to prevent (see `adapter.py` for the house style).

+ 2 - 3
adapter.py

@@ -2212,14 +2212,13 @@ class ChattoAdapter(BasePlatformAdapter):
                 logger.error("Chatto: CompleteUpload returned no asset")
                 return None
 
-            asset_id = asset.id
             logger.info(
                 "Chatto: uploaded %s as asset %s (%d bytes)",
                 file_name,
-                asset_id,
+                asset.id,
                 file_size,
             )
-            return asset_id
+            return asset.id
 
         except ChattoError as e:
             logger.error("Chatto: upload failed: %s", e)