python-introspect 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- python_introspect-0.1.0/LICENSE +21 -0
- python_introspect-0.1.0/PKG-INFO +133 -0
- python_introspect-0.1.0/README.md +99 -0
- python_introspect-0.1.0/pyproject.toml +70 -0
- python_introspect-0.1.0/setup.cfg +4 -0
- python_introspect-0.1.0/src/python_introspect/__init__.py +48 -0
- python_introspect-0.1.0/src/python_introspect/exceptions.py +21 -0
- python_introspect-0.1.0/src/python_introspect/signature_analyzer.py +1148 -0
- python_introspect-0.1.0/src/python_introspect/unified_parameter_analyzer.py +275 -0
- python_introspect-0.1.0/src/python_introspect.egg-info/PKG-INFO +133 -0
- python_introspect-0.1.0/src/python_introspect.egg-info/SOURCES.txt +16 -0
- python_introspect-0.1.0/src/python_introspect.egg-info/dependency_links.txt +1 -0
- python_introspect-0.1.0/src/python_introspect.egg-info/requires.txt +11 -0
- python_introspect-0.1.0/src/python_introspect.egg-info/top_level.txt +1 -0
- python_introspect-0.1.0/tests/test_exceptions.py +94 -0
- python_introspect-0.1.0/tests/test_init.py +139 -0
- python_introspect-0.1.0/tests/test_signature_analyzer.py +407 -0
- python_introspect-0.1.0/tests/test_unified_parameter_analyzer.py +353 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Tristan Simas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-introspect
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pure Python introspection toolkit for function signatures, dataclasses, and type hints
|
|
5
|
+
Author-email: Tristan Simas <tristan.simas@mail.mcgill.ca>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/OpenHCSDev/python-introspect
|
|
8
|
+
Project-URL: Repository, https://github.com/OpenHCSDev/python-introspect
|
|
9
|
+
Project-URL: Issues, https://github.com/OpenHCSDev/python-introspect/issues
|
|
10
|
+
Keywords: introspection,reflection,signature,dataclass,type-hints,docstring
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
26
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
29
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
30
|
+
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: mkdocs>=1.5.0; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# python-introspect
|
|
36
|
+
|
|
37
|
+
**Pure Python introspection toolkit for function signatures, dataclasses, and type hints**
|
|
38
|
+
|
|
39
|
+
[](https://www.python.org/downloads/)
|
|
40
|
+
[](https://opensource.org/licenses/MIT)
|
|
41
|
+
[](https://github.com/trissim/python-introspect/actions/workflows/ci.yml)
|
|
42
|
+
[](https://badge.fury.io/py/python-introspect)
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- 🔍 **Function/Method Signature Analysis** - Extract parameter info from any callable
|
|
47
|
+
- 📦 **Dataclass Field Extraction** - Analyze dataclass fields and types
|
|
48
|
+
- 📝 **Docstring Parsing** - Extract and parse docstrings (Google, NumPy, Sphinx styles)
|
|
49
|
+
- 🏷️ **Type Hint Resolution** - Resolve complex type hints and annotations
|
|
50
|
+
- 🎯 **Unified API** - Single interface for all parameter sources
|
|
51
|
+
- 🚀 **Pure Python** - No external dependencies, pure stdlib
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install python-introspect
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from python_introspect import SignatureAnalyzer
|
|
63
|
+
|
|
64
|
+
def example_function(name: str, age: int = 25, *, active: bool = True):
|
|
65
|
+
"""
|
|
66
|
+
Example function with parameters.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
name: The person's name
|
|
70
|
+
age: The person's age
|
|
71
|
+
active: Whether the person is active
|
|
72
|
+
"""
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
# Analyze the function
|
|
76
|
+
analyzer = SignatureAnalyzer()
|
|
77
|
+
params = analyzer.analyze_function(example_function)
|
|
78
|
+
|
|
79
|
+
for param in params:
|
|
80
|
+
print(f"{param.name}: {param.annotation} = {param.default}")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Use Cases
|
|
84
|
+
|
|
85
|
+
- **Form Generation** - Generate UI forms from function signatures
|
|
86
|
+
- **API Documentation** - Auto-generate API docs from code
|
|
87
|
+
- **Configuration Validation** - Validate config against function parameters
|
|
88
|
+
- **Dynamic UI** - Build dynamic UIs based on function signatures
|
|
89
|
+
- **Parameter Analysis** - Analyze and validate function parameters
|
|
90
|
+
|
|
91
|
+
## Documentation
|
|
92
|
+
|
|
93
|
+
Full documentation available at: https://github.com/trissim/python-introspect
|
|
94
|
+
|
|
95
|
+
## Development
|
|
96
|
+
|
|
97
|
+
### Setup
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Clone the repository
|
|
101
|
+
git clone https://github.com/trissim/python-introspect.git
|
|
102
|
+
cd python-introspect
|
|
103
|
+
|
|
104
|
+
# Create virtual environment
|
|
105
|
+
python -m venv venv
|
|
106
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
107
|
+
|
|
108
|
+
# Install in development mode with dev dependencies
|
|
109
|
+
pip install -e ".[dev]"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Running Tests
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Run all tests
|
|
116
|
+
pytest tests/
|
|
117
|
+
|
|
118
|
+
# Run with coverage
|
|
119
|
+
pytest tests/ --cov=python_introspect --cov-report=term --cov-report=html
|
|
120
|
+
|
|
121
|
+
# Run linting and formatting checks
|
|
122
|
+
ruff check src/ tests/
|
|
123
|
+
black --check src/ tests/
|
|
124
|
+
mypy src/python_introspect/
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
130
|
+
|
|
131
|
+
## Credits
|
|
132
|
+
|
|
133
|
+
Developed by Tristan Simas as part of the OpenHCS project.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# python-introspect
|
|
2
|
+
|
|
3
|
+
**Pure Python introspection toolkit for function signatures, dataclasses, and type hints**
|
|
4
|
+
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/trissim/python-introspect/actions/workflows/ci.yml)
|
|
8
|
+
[](https://badge.fury.io/py/python-introspect)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🔍 **Function/Method Signature Analysis** - Extract parameter info from any callable
|
|
13
|
+
- 📦 **Dataclass Field Extraction** - Analyze dataclass fields and types
|
|
14
|
+
- 📝 **Docstring Parsing** - Extract and parse docstrings (Google, NumPy, Sphinx styles)
|
|
15
|
+
- 🏷️ **Type Hint Resolution** - Resolve complex type hints and annotations
|
|
16
|
+
- 🎯 **Unified API** - Single interface for all parameter sources
|
|
17
|
+
- 🚀 **Pure Python** - No external dependencies, pure stdlib
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install python-introspect
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from python_introspect import SignatureAnalyzer
|
|
29
|
+
|
|
30
|
+
def example_function(name: str, age: int = 25, *, active: bool = True):
|
|
31
|
+
"""
|
|
32
|
+
Example function with parameters.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name: The person's name
|
|
36
|
+
age: The person's age
|
|
37
|
+
active: Whether the person is active
|
|
38
|
+
"""
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
# Analyze the function
|
|
42
|
+
analyzer = SignatureAnalyzer()
|
|
43
|
+
params = analyzer.analyze_function(example_function)
|
|
44
|
+
|
|
45
|
+
for param in params:
|
|
46
|
+
print(f"{param.name}: {param.annotation} = {param.default}")
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Use Cases
|
|
50
|
+
|
|
51
|
+
- **Form Generation** - Generate UI forms from function signatures
|
|
52
|
+
- **API Documentation** - Auto-generate API docs from code
|
|
53
|
+
- **Configuration Validation** - Validate config against function parameters
|
|
54
|
+
- **Dynamic UI** - Build dynamic UIs based on function signatures
|
|
55
|
+
- **Parameter Analysis** - Analyze and validate function parameters
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
Full documentation available at: https://github.com/trissim/python-introspect
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
### Setup
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Clone the repository
|
|
67
|
+
git clone https://github.com/trissim/python-introspect.git
|
|
68
|
+
cd python-introspect
|
|
69
|
+
|
|
70
|
+
# Create virtual environment
|
|
71
|
+
python -m venv venv
|
|
72
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
73
|
+
|
|
74
|
+
# Install in development mode with dev dependencies
|
|
75
|
+
pip install -e ".[dev]"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Running Tests
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Run all tests
|
|
82
|
+
pytest tests/
|
|
83
|
+
|
|
84
|
+
# Run with coverage
|
|
85
|
+
pytest tests/ --cov=python_introspect --cov-report=term --cov-report=html
|
|
86
|
+
|
|
87
|
+
# Run linting and formatting checks
|
|
88
|
+
ruff check src/ tests/
|
|
89
|
+
black --check src/ tests/
|
|
90
|
+
mypy src/python_introspect/
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Contributing
|
|
94
|
+
|
|
95
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
96
|
+
|
|
97
|
+
## Credits
|
|
98
|
+
|
|
99
|
+
Developed by Tristan Simas as part of the OpenHCS project.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "python-introspect"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Pure Python introspection toolkit for function signatures, dataclasses, and type hints"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Tristan Simas", email = "tristan.simas@mail.mcgill.ca"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["introspection", "reflection", "signature", "dataclass", "type-hints", "docstring"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Topic :: Utilities",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = []
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=7.0",
|
|
34
|
+
"pytest-cov>=4.0",
|
|
35
|
+
"ruff>=0.1.0",
|
|
36
|
+
"black>=23.0",
|
|
37
|
+
"mypy>=1.0",
|
|
38
|
+
]
|
|
39
|
+
docs = [
|
|
40
|
+
"mkdocs>=1.5.0",
|
|
41
|
+
"mkdocs-material>=9.0.0",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[project.urls]
|
|
45
|
+
Homepage = "https://github.com/OpenHCSDev/python-introspect"
|
|
46
|
+
Repository = "https://github.com/OpenHCSDev/python-introspect"
|
|
47
|
+
Issues = "https://github.com/OpenHCSDev/python-introspect/issues"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
where = ["src"]
|
|
51
|
+
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
testpaths = ["tests"]
|
|
54
|
+
python_files = ["test_*.py"]
|
|
55
|
+
python_classes = ["Test*"]
|
|
56
|
+
python_functions = ["test_*"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 100
|
|
60
|
+
target-version = "py39"
|
|
61
|
+
|
|
62
|
+
[tool.black]
|
|
63
|
+
line-length = 100
|
|
64
|
+
target-version = ["py39"]
|
|
65
|
+
|
|
66
|
+
[tool.mypy]
|
|
67
|
+
python_version = "3.9"
|
|
68
|
+
warn_return_any = true
|
|
69
|
+
warn_unused_configs = true
|
|
70
|
+
disallow_untyped_defs = true
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""
|
|
2
|
+
python-introspect: Pure Python introspection toolkit
|
|
3
|
+
|
|
4
|
+
This package provides utilities for introspecting Python functions, methods,
|
|
5
|
+
dataclasses, and type hints.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.2"
|
|
9
|
+
|
|
10
|
+
from .signature_analyzer import (
|
|
11
|
+
SignatureAnalyzer,
|
|
12
|
+
ParameterInfo,
|
|
13
|
+
DocstringInfo,
|
|
14
|
+
DocstringExtractor,
|
|
15
|
+
register_namespace_provider,
|
|
16
|
+
register_type_resolver,
|
|
17
|
+
)
|
|
18
|
+
from .unified_parameter_analyzer import (
|
|
19
|
+
UnifiedParameterAnalyzer,
|
|
20
|
+
UnifiedParameterInfo,
|
|
21
|
+
)
|
|
22
|
+
from .exceptions import (
|
|
23
|
+
IntrospectionError,
|
|
24
|
+
SignatureAnalysisError,
|
|
25
|
+
DocstringParsingError,
|
|
26
|
+
TypeResolutionError,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
# Version
|
|
31
|
+
"__version__",
|
|
32
|
+
# Signature analysis
|
|
33
|
+
"SignatureAnalyzer",
|
|
34
|
+
"ParameterInfo",
|
|
35
|
+
"DocstringInfo",
|
|
36
|
+
"DocstringExtractor",
|
|
37
|
+
# Unified analysis
|
|
38
|
+
"UnifiedParameterAnalyzer",
|
|
39
|
+
"UnifiedParameterInfo",
|
|
40
|
+
# Plugin system
|
|
41
|
+
"register_namespace_provider",
|
|
42
|
+
"register_type_resolver",
|
|
43
|
+
# Exceptions
|
|
44
|
+
"IntrospectionError",
|
|
45
|
+
"SignatureAnalysisError",
|
|
46
|
+
"DocstringParsingError",
|
|
47
|
+
"TypeResolutionError",
|
|
48
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Exceptions for python-introspect."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class IntrospectionError(Exception):
|
|
5
|
+
"""Base exception for introspection errors."""
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SignatureAnalysisError(IntrospectionError):
|
|
10
|
+
"""Exception raised when signature analysis fails."""
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class DocstringParsingError(IntrospectionError):
|
|
15
|
+
"""Exception raised when docstring parsing fails."""
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TypeResolutionError(IntrospectionError):
|
|
20
|
+
"""Exception raised when type resolution fails."""
|
|
21
|
+
pass
|