{"id":881,"library":"inflect","title":"Inflect","description":"Inflect.py is a Python library designed to correctly generate plurals, singular nouns, ordinals, indefinite articles (a/an), and word-based representations of numbers. Its functionality is primarily focused on the English language. As of version 7.5.0, it maintains an active development and release cadence, with regular updates addressing features, bug fixes, and compatibility.","status":"active","version":"7.5.0","language":"python","source_language":"en","source_url":"https://github.com/jaraco/inflect","tags":["natural language processing","nlp","text processing","grammar","pluralization","ordinals"],"install":[{"cmd":"pip install inflect","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Runtime dependency for iterable utilities.","package":"more-itertools","optional":false},{"reason":"Runtime dependency for runtime type checking (introduced in v7.2.0 to replace Pydantic).","package":"typeguard","optional":false},{"reason":"Runtime dependency for backported typing features, even for Python 3.9+ environments.","package":"typing_extensions","optional":false}],"imports":[{"note":"The primary way to interact with the library is through an instance of the engine class.","symbol":"engine","correct":"import inflect\np = inflect.engine()"}],"quickstart":{"code":"import inflect\n\np = inflect.engine()\n\n# Pluralization\nword = 'cat'\ncount = 5\nprint(f\"The plural of '{word}' is '{p.plural(word)}'\")\nprint(f\"I saw {count} {p.plural_noun(word, count)}.\")\n\n# Ordinal numbers\nnumber = 21\nprint(f\"The ordinal of {number} is {p.ordinal(number)}\")\n\n# Numbers to words\nbig_number = 1234567\nprint(f\"'{big_number}' in words is '{p.number_to_words(big_number)}'\")\n\n# Indefinite articles\nprint(f\"An apple and {p.an('historical object')}\")","lang":"python","description":"This quickstart demonstrates common `inflect` functionalities: pluralizing nouns conditionally, generating ordinal numbers, converting numerals to words, and selecting indefinite articles ('a' or 'an')."},"warnings":[{"fix":"Refer to the `inflect` documentation for current method names and update your code accordingly. These typically involve methods for singular/plural inflection.","message":"Version 7.0.0 removed methods that were renamed in an earlier 0.2.0 release. If your code uses very old aliases, they will cease to function.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Always provide the correct base form (singular for pluralization, plural for singularization) to the respective `inflect.engine()` methods.","message":"When using methods like `plural_noun()`, ensure you pass the *singular* form of the word. Similarly, `singular_noun()` expects the *plural* form. Passing the incorrect base form can lead to undefined or incorrect inflections.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade `inflect` to the latest v7.x version. If issues persist, ensure your environment's Pydantic (if present) and `inflect` versions are compatible, or isolate `inflect` in a separate virtual environment.","message":"Older versions (pre-7.2.0, particularly in the v6.x series) experienced compatibility issues with Pydantic, leading to `ValueError` (e.g., `ValueError: Field default cannot be set in Annotated`). This was often due to Pydantic 1 vs. 2 conflicts. While v7.2.0 replaced Pydantic with Typeguard, users with existing Pydantic installations in their environment might still encounter conflicts if older `inflect` versions are used or if a new conflict arises.","severity":"gotcha","affected_versions":"Primarily pre-7.2.0; potential for environment conflicts in any version."},{"fix":"Consider using `print(p.inflect('num({0}) plural_noun(error) plural_verb(was) detected.'.format(errors)))` instead of `print(p.num(errors), p.plural_noun(' error'), p.plural_verb(' was'), ' detected.')`.","message":"For combining multiple inflections within a single string, the `p.inflect()` string-interpolating method is generally more readable and efficient than concatenating multiple method calls.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T20:44:04.547Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"pip install inflect","cause":"The 'inflect' library is not installed in the current Python environment or the environment is not properly activated.","error":"ModuleNotFoundError: No module named 'inflect'"},{"fix":"Upgrade 'inflect' to the latest version (7.2.0 or higher) using `pip install --upgrade inflect`, or downgrade Pydantic to a 1.x version using `pip install 'pydantic<2'`.","cause":"This error arises from compatibility issues between older versions of 'inflect' (pre-7.2.0) and Pydantic v2.x, as 'inflect' versions 7.2.0 and later replaced Pydantic with Typeguard.","error":"ValueError: `Field` default cannot be set in `Annotated`"},{"fix":"Always provide the correct base form (singular for pluralization, plural for singularization) to the respective `inflect.engine()` methods. For example, use `p.plural('cat')` for pluralizing 'cat' and `p.singular_noun('people')` for singularizing 'people'.","cause":"The 'plural()' methods (like `p.plural()`, `p.plural_noun()`) expect a singular form of the word, and 'singular_noun()' expects a plural form. Passing the incorrect base form results in undefined or incorrect inflections.","error":"Incorrect pluralization/singularization output (e.g., p.plural(\"cats\") returns \"catses\")"},{"fix":"import inflect\np = inflect.engine()\nword = p.plural(\"cat\")","cause":"Methods like 'plural' are available on an inflect.engine() object, not directly on the inflect module itself.","error":"AttributeError: module 'inflect' has no attribute 'plural'"},{"fix":"import inflect\np = inflect.engine()\n# Configuration options are set on the engine instance, e.g.:\np.classical(all=False)\np.no(\"and\")","cause":"The inflect.engine() constructor does not accept any arguments; configuration is done via attributes on the returned engine object.","error":"TypeError: inflect.engine() takes no arguments"}],"ecosystem":"pypi","meta_description":null,"install_score":85,"install_tag":"verified","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"7.5.0","cli_name":"","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":4.99,"mem_mb":19.3,"disk_size":"19.1M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.64,"mem_mb":19.3,"disk_size":"19.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":3.38,"mem_mb":19.3,"disk_size":"20M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.82,"mem_mb":19.3,"disk_size":"20M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":5.91,"mem_mb":20.5,"disk_size":"21.2M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":6.75,"mem_mb":20.5,"disk_size":"21.2M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":5.1,"mem_mb":20.5,"disk_size":"22M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.01,"mem_mb":20.5,"disk_size":"22M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":5.63,"mem_mb":20.3,"disk_size":"13.0M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":7,"mem_mb":20.3,"disk_size":"13.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.6,"import_time_s":5.4,"mem_mb":20.3,"disk_size":"14M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.73,"mem_mb":20.3,"disk_size":"14M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":5.73,"mem_mb":20.7,"disk_size":"12.8M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":6.46,"mem_mb":20.7,"disk_size":"12.7M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.7,"import_time_s":5.45,"mem_mb":20.6,"disk_size":"13M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.95,"mem_mb":20.6,"disk_size":"13M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":4.98,"mem_mb":19.8,"disk_size":"19.0M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.98,"mem_mb":19.8,"disk_size":"19.0M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.2,"import_time_s":4.18,"mem_mb":19.8,"disk_size":"19M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.74,"mem_mb":19.8,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}