{"id":23725,"library":"fields","title":"Fields","description":"A Python library for eliminating class boilerplate by providing an attrs/dataclass-like container class with built-in validation and transformation. Current version is 5.0.0, released on 2025-12-05. Development appears slow; pre-5.0.0 releases were irregular.","status":"active","version":"5.0.0","language":"python","source_language":"en","source_url":"https://github.com/ionelmc/python-fields","tags":["metaclass","class decorator","validation","container","boilerplate"],"install":[{"cmd":"pip install fields","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Field is exported at package level; no submodule needed.","wrong":"from fields.field import Field","symbol":"Field","correct":"from fields import Field"},{"note":"Direct import gives you the decorator; for container use 'from fields import fields'.","wrong":"import fields","symbol":"fields","correct":"from fields import fields"}],"quickstart":{"code":"from fields import fields, Field\n\n@fields\nclass Point:\n    x: int = Field(required=True)\n    y: int = 0\n\np = Point(x=3)\nprint(p.x, p.y)  # 3 0","lang":"python","description":"Define a container class with automatic __init__, __repr__, and validation via type hints and Field descriptors."},"warnings":[{"fix":"Define classmethods/staticmethods outside the @fields class or use a different decorator pattern.","message":"Classmethod and staticmethod descriptors conflict with field inspection; avoid using them inside @fields classes.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use keyword argument 'name' only when necessary; prefer relying on the variable name.","message":"Field name checking uses both the slot name and the variable name; renaming a field variable but not updating the Field's 'name' argument can cause silent failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Replace Field(validate=func) with Field(check=func).","message":"The 'validate' parameter in Field is deprecated in 5.0.0; use the 'check' parameter instead.","severity":"deprecated","affected_versions":"5.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Fields are descriptors; access via instance attribute, not class attribute. Use instance.field_name.","cause":"Trying to call a Field instance as a function (e.g., after defining it as a class attribute).","error":"TypeError: 'Field' object is not callable"},{"fix":"Pass all required fields as keyword arguments to the constructor.","cause":"Required field not provided during instantiation.","error":"ValueError: Field 'x' is required"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}