{"id":24774,"library":"types-pynput","title":"Typing stubs for pynput","description":"This package provides type annotations (stubs) for the `pynput` library, allowing type checkers like mypy and pyright to validate code that uses pynput. Current version is 1.8.1.20260408, compatible with Python >=3.10. It is part of the typeshed project and is updated regularly to match upstream pynput releases.","status":"active","version":"1.8.1.20260408","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","pynput","type-hints"],"install":[{"cmd":"pip install types-pynput","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Stubs only type-check code using pynput; pynput must be installed at runtime.","package":"pynput","optional":false}],"imports":[{"wrong":"from pynput import keyboard","symbol":"keyboard","correct":"from pynput-stubs import keyboard"},{"wrong":"from pynput import mouse","symbol":"mouse","correct":"from pynput-stubs import mouse"}],"quickstart":{"code":"from pynput import keyboard\n\ndef on_press(key):\n    try:\n        print(f'Alphanumeric key pressed: {key.char}')\n    except AttributeError:\n        print(f'Special key pressed: {key}')\n\nwith keyboard.Listener(on_press=on_press) as listener:\n    listener.join()","lang":"python","description":"Quickstart showing a basic keyboard listener with type stubs active."},"warnings":[{"fix":"Install both: pip install pynput types-pynput","message":"types-pynput only provides type hints; it must be installed alongside the runtime library pynput. Running code without pynput will raise ImportError.","severity":"gotcha","affected_versions":"all"},{"fix":"Use explicit submodule imports: from pynput import keyboard, mouse","message":"In some older stubs, importing directly from 'pynput' may not include submodule types. Always import from the specific submodule (e.g., 'from pynput import keyboard') to get correct type inference.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.8.1.20260408':31 '3.10':35 'allow':15 'annot':9 'checker':17 'code':24 'compat':32 'current':28 'hint':57 'librari':14 'like':18 'match':48 'mypi':19 'packag':6 'part':38 'project':42 'provid':7 'pynput':4,13,27,50,54 'pyright':21 'python':34 'regular':46 'releas':51 'stub':2,10,53 'type':1,8,16,52,56 'type-hint':55 'typesh':41 'updat':45 'upstream':49 'use':26 'valid':23 'version':29","created_at":"2026-05-01T08:14:51.238696+00:00","updated_at":"2026-05-01T08:14:51.238696+00:00","problems":{"verify_error":"File \"<string>\", line 1\n    from pynput-stubs import keyboard\n               ^\nSyntaxError: invalid syntax"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.8.1.20260603","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/typeshed-internal/stub_uploader","docs":null,"changelog":"https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/pynput.md","pypi":"https://pypi.org/project/types-pynput/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}