{"id":9344,"library":"sty","title":"Sty","description":"Sty is a Python library that provides a simple, customizable, and performant string styling markup for terminal output, decoupled from specific color palettes and terminal implementations. It supports 3/4bit, 8bit, and 24bit (truecolor/RGB) colors, as well as effects like bold, italic, and underline. Currently at version 1.0.6, Sty follows semantic versioning and aims to maintain backward compatibility for 1.x.x releases after 1.0.0. It has no external dependencies and is actively maintained.","status":"active","version":"1.0.6","language":"en","source_language":"en","source_url":"https://github.com/feluxe/sty","tags":["styling","color","terminal","ansi","command-line","cli"],"install":[{"cmd":"pip install sty","lang":"bash","label":"Install latest stable version"}],"dependencies":[],"imports":[{"note":"Importing style objects directly is the recommended and most common pattern for convenient access to foreground, background, effects, and reset registers.","symbol":"fg, bg, ef, rs","correct":"from sty import fg, bg, ef, rs"}],"quickstart":{"code":"from sty import fg, bg, ef, rs\n\n# Basic colors\nprint(fg.red + 'This is red text!' + fg.rs)\nprint(bg.blue + 'This has a blue background!' + bg.rs)\n\n# Effects\nprint(ef.bold + 'This is bold text' + ef.rs)\nprint(ef.italic + 'This is italic text' + ef.rs)\n\n# 8-bit colors\nprint(fg(201) + 'This is pink text using 8bit colors' + fg.rs)\n\n# 24-bit (RGB) colors\nprint(fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs)\n\n# Combine styles\nprint(fg.green + bg.yellow + ef.bold + 'Green text on yellow background, bold!' + rs.all)\n","lang":"python","description":"This quickstart demonstrates how to import and apply various foreground and background colors, as well as text effects. It shows examples for standard, 8-bit, and 24-bit RGB colors, and how to combine and reset styles using the provided register objects (`fg`, `bg`, `ef`, `rs`)."},"warnings":[{"fix":"Customize styling by directly assigning `Rule` objects to the registers (e.g., `fg.red = Rule(Render.rgb_fg, 255, 0, 0)`). Refer to the official documentation for current customization patterns.","message":"Methods `.set_style()` and `.get_style()` were removed in v1.0.0-rc.1. They were deprecated in v1.0.0-beta.12. Using these methods in v1.0.0 or later will result in an AttributeError.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update all instances of `sty.rs.rs` to `sty.rs.ef` to correctly apply the reset effect. The `rs.all` property can be used to reset all styles simultaneously.","message":"The reset register attribute `sty.rs.rs` was renamed to `sty.rs.ef` in v1.0.0-rc.2 due to a typo fix. Code using the old `sty.rs.rs` will fail with an AttributeError in subsequent versions.","severity":"breaking","affected_versions":">=1.0.0-rc.2"},{"fix":"Review and adjust any custom grey color definitions or assumptions based on the new palette definitions. You can define custom colors using `Rule` and `Render` classes.","message":"The grey color palette definitions were changed in v1.0.0-rc.0. If your application relies on specific grey values from pre-release versions, the visual output might differ.","severity":"breaking","affected_versions":">=1.0.0-rc.0"},{"fix":"Adopt the direct import pattern: `from sty import fg, bg, ef, rs`. This makes your code cleaner and aligns with the library's design.","message":"While `import sty` and then referencing `sty.fg`, `sty.bg`, etc., technically works, the idiomatic and recommended approach for convenience and better performance is to directly import the register objects: `from sty import fg, bg, ef, rs`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Instead of `register.set_style(...)`, directly assign `Rule` objects to define custom styles, e.g., `fg.custom_color = Rule(Render.rgb_fg, 100, 200, 50)`.","cause":"Attempting to use the `set_style()` method, which was removed in `sty` v1.0.0-rc.1.","error":"AttributeError: 'Register' object has no attribute 'set_style'"},{"fix":"Change `sty.rs.rs` to `sty.rs.ef` or use `rs.all` to reset all styles. For example, `print(fg.red + 'text' + rs.ef)` or `print(fg.red + 'text' + rs.all)`.","cause":"Attempting to use the `sty.rs.rs` attribute after it was renamed to `sty.rs.ef` in `sty` v1.0.0-rc.2.","error":"AttributeError: 'Reset' object has no attribute 'rs'"},{"fix":"Always import public symbols directly from the `sty` package, e.g., `from sty import fg, bg, ef, rs`. The `sty.lib` path is for internal use.","cause":"Trying to import internal modules like `sty.lib` directly. These are not part of the public API and their structure can change.","error":"ModuleNotFoundError: No module named 'sty.lib'"}]}