Decomposition 2026 11 05
ASecurityif isinstance(total_seconds, bool) or not isinstance(total_seconds, int): raise TypeError( f"total_seconds: ожидался int, получен {type(total_seconds).__name__}" ) if total_seconds < 0: raise ValueError(f"total_seconds: ожидалось >= 0, получено {total_seconds}") hours, rest = divmod(total_seconds, 3600) minutes = rest // 60 if hours: return f"{hours}ч {minutes}м" return f"{minutes}м" ``` **Проверка:** ```python assert seconds_to_hm(0) == "0м" assert seconds_to_hm(90) == "1м" assert seconds_to...
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added November 11, 2026
Security analysis
100/100Pro scans all 21 files and shows the line behind each finding
npx -y skills add Siririn77/i-have-autism --skill decomposition-2026-11-05 --agent claude-codeAre you the author of Decomposition 2026 11 05?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/siririn77-decomposition-2026-11-05-b3a571d4)Файл `seconds_to_hm.py`, ниже — функция целиком.
**Граф (4 узла):**
1. **Что:** выходные единицы — только часы и минуты. **Почему:** формат задан как «1ч 20м», секунд в нём нет. **Якорь:** `divmod(total_seconds, 3600)`. **Когда:** всегда.
2. **Что:** секунды отбрасываются, а не округляются. **Почему:** 90 с при округлении дали бы «2м» — это ложь о входе. **Якорь:** `rest // 60`. **Когда:** всегда.
3. **Что:** отрицательное и не-int отвергаются до арифметики. **Почему:** `divmod(-90, 3600)` даёт `(-1, 3510)` → «-1ч 58м», бессмыслица. **Якорь:** два `raise`. **Когда:** на входе.
4. **Что:** при нуле часов часть «0ч» не печатается. **Почему:** «40м» читается, «0ч 40м» — шум. **Якорь:** `if hours:`. **Когда:** `total_seconds < 3600`.
```python
def seconds_to_hm(total_seconds: int) -> str:
"""Секунды -> «1ч 20м». Нецелые и отрицательные значения — ошибка."""
# Проверки до арифметики: divmod на отрицательном числе даёт верные
# по модулю часы и мусорные минуты, чинить это после форматирования поздно.
if isinstance(total_seconds, bool) or not isinstance(total_seconds, int):
raise TypeError(
f"total_seconds: ожидался int, получен {type(total_seconds).__name__}"
)
if total_seconds < 0:
raise ValueError(f"total_seconds: ожидалось >= 0, получено {total_seconds}")
hours, rest = divmod(total_seconds, 3600)
# Секунды отбрасываем: формат «1ч 20м» их не показывает,
# округление вверх соврало бы о длительности.
minutes = rest // 60
if hours:
return f"{hours}ч {minutes}м"
return f"{minutes}м"
```
**Проверка:**
```python
assert seconds_to_hm(0) == "0м"
assert seconds_to_hm(90) == "1м"
assert seconds_to_hm(4800) == "1ч 20м"
assert seconds_to_hm(3600) == "1ч 0м"
```
Запуск: `python -c "from seconds_to_hm import seconds_to_hm; print(seconds_to_hm(4800))"` → `1ч 20м`.
**Что осталось за рамками:** `total_seconds=3599.9` (float) не принимается — сигнатура объявляет `int`. Если нужны доли секунды, это отдельное решение о том, что печатать в остатке.Files in this skill
- SCORE.md
- answer-estimate_with-skill.md
- answer-estimate_without-skill.md
- answer-next-step_with-skill.md
- answer-next-step_without-skill.md
- answer-no-preamble_with-skill.md
- answer-no-preamble_without-skill.md
- cases.json
- code-edge-negative_with-skill.md
- code-edge-negative_without-skill.md
- comment-says-why_with-skill.md
- comment-says-why_without-skill.md
- decomposition-huge_with-skill.md
- decomposition-huge_without-skill.md
- decomposition-small_with-skill.md
- decomposition-small_without-skill.md
- destructive-needs-confirmation_with-skill.md
- destructive-needs-confirmation_without-skill.md
- disagree-first-line_with-skill.md
- disagree-first-line_without-skill.md
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.