shikake 0.0.1__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.
- shikake-0.0.1/CHANGELOG.md +41 -0
- shikake-0.0.1/LICENSE +21 -0
- shikake-0.0.1/MANIFEST.in +18 -0
- shikake-0.0.1/Makefile +15 -0
- shikake-0.0.1/PKG-INFO +144 -0
- shikake-0.0.1/README.md +116 -0
- shikake-0.0.1/devdocs/__init__.py +0 -0
- shikake-0.0.1/devdocs/build_api_index.py +76 -0
- shikake-0.0.1/devdocs/canonical_sources/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/api_reference/__init__.py +1 -0
- shikake-0.0.1/devdocs/canonical_sources/api_reference/external.py +283 -0
- shikake-0.0.1/devdocs/canonical_sources/api_reference/public.py +765 -0
- shikake-0.0.1/devdocs/canonical_sources/changelog/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/changelog/canonical.py +83 -0
- shikake-0.0.1/devdocs/canonical_sources/development_history/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/development_history/performance.py +74 -0
- shikake-0.0.1/devdocs/canonical_sources/development_history/pre_release.py +1051 -0
- shikake-0.0.1/devdocs/canonical_sources/documentation_policy/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/documentation_policy/canonical.py +66 -0
- shikake-0.0.1/devdocs/canonical_sources/policy/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/policy/canonical.py +79 -0
- shikake-0.0.1/devdocs/canonical_sources/readme/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/readme/canonical.py +185 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/binding.py +119 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/expressions.py +353 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/external.py +110 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/layouts.py +582 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/model.py +165 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/parsing.py +205 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/relations.py +158 -0
- shikake-0.0.1/devdocs/canonical_sources/specification/statements.py +357 -0
- shikake-0.0.1/devdocs/canonical_sources/status/__init__.py +0 -0
- shikake-0.0.1/devdocs/canonical_sources/status/canonical.py +79 -0
- shikake-0.0.1/devdocs/context.json +5 -0
- shikake-0.0.1/devdocs/generate.py +118 -0
- shikake-0.0.1/docs/DOCUMENTATION_POLICY.md +47 -0
- shikake-0.0.1/docs/STATUS.md +63 -0
- shikake-0.0.1/docs/api_reference/INDEX.md +82 -0
- shikake-0.0.1/docs/api_reference/external.md +243 -0
- shikake-0.0.1/docs/api_reference/public.md +608 -0
- shikake-0.0.1/pyproject.toml +63 -0
- shikake-0.0.1/setup.cfg +4 -0
- shikake-0.0.1/src/shikake/__init__.py +71 -0
- shikake-0.0.1/src/shikake/_mica/__init__.py +45 -0
- shikake-0.0.1/src/shikake/_mica/ast_facts.py +619 -0
- shikake-0.0.1/src/shikake/_mica/base_references.py +48 -0
- shikake-0.0.1/src/shikake/_mica/class_hierarchy.py +152 -0
- shikake-0.0.1/src/shikake/_mica/external_structures.py +429 -0
- shikake-0.0.1/src/shikake/_mica/import_policy.py +136 -0
- shikake-0.0.1/src/shikake/_mica/inspection.py +437 -0
- shikake-0.0.1/src/shikake/_mica/kinds/__init__.py +5 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/__init__.py +5 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/augmented_assignment.py +87 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/contracts.py +18 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/control.py +44 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/core.py +13 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/definition.py +83 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/imports.py +26 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/package.py +9 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/pattern.py +68 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/statement.py +95 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/structure.py +100 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/structures.py +396 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/__init__.py +1 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/access.py +20 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/basic.py +120 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/call.py +9 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/collection.py +32 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/comprehension.py +42 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/operation/__init__.py +1 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/operation/arithmetic.py +86 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/operation/comparison.py +74 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/operation/logical.py +21 -0
- shikake-0.0.1/src/shikake/_mica/kinds/description/value/operation/unary.py +33 -0
- shikake-0.0.1/src/shikake/_mica/kinds/index.py +259 -0
- shikake-0.0.1/src/shikake/_mica/kinds/regulation.py +109 -0
- shikake-0.0.1/src/shikake/_mica/model.py +438 -0
- shikake-0.0.1/src/shikake/_mica/modeling/__init__.py +1 -0
- shikake-0.0.1/src/shikake/_mica/modeling/base313.py +592 -0
- shikake-0.0.1/src/shikake/_mica/modeling/common.py +108 -0
- shikake-0.0.1/src/shikake/_mica/modeling/python314.py +64 -0
- shikake-0.0.1/src/shikake/_mica/modeling/python315.py +41 -0
- shikake-0.0.1/src/shikake/_mica/package.py +267 -0
- shikake-0.0.1/src/shikake/_mica/parser.py +760 -0
- shikake-0.0.1/src/shikake/_mica/position.py +22 -0
- shikake-0.0.1/src/shikake/_mica/py.typed +0 -0
- shikake-0.0.1/src/shikake/_mica/reference_resolution.py +154 -0
- shikake-0.0.1/src/shikake/_mica/relation_analysis.py +167 -0
- shikake-0.0.1/src/shikake/_mica/relation_facts.py +601 -0
- shikake-0.0.1/src/shikake/_mica/tree_display.py +93 -0
- shikake-0.0.1/src/shikake/external/__init__.py +355 -0
- shikake-0.0.1/src/shikake/py.typed +0 -0
- shikake-0.0.1/src/shikake.egg-info/PKG-INFO +144 -0
- shikake-0.0.1/src/shikake.egg-info/SOURCES.txt +182 -0
- shikake-0.0.1/src/shikake.egg-info/dependency_links.txt +1 -0
- shikake-0.0.1/src/shikake.egg-info/requires.txt +6 -0
- shikake-0.0.1/src/shikake.egg-info/top_level.txt +1 -0
- shikake-0.0.1/tests/external_colliding_definitions.py +31 -0
- shikake-0.0.1/tests/external_memory_definitions.py +49 -0
- shikake-0.0.1/tests/fixtures/binding_patterns.py +17 -0
- shikake-0.0.1/tests/fixtures/context_comprehensions.py +16 -0
- shikake-0.0.1/tests/fixtures/fee_adjustments.py +18 -0
- shikake-0.0.1/tests/fixtures/generator_subject.py +31 -0
- shikake-0.0.1/tests/fixtures/order_calculation.py +63 -0
- shikake-0.0.1/tests/fixtures/quote_rules.py +25 -0
- shikake-0.0.1/tests/fixtures/shipping.py +18 -0
- shikake-0.0.1/tests/fixtures/shop/__init__.py +0 -0
- shikake-0.0.1/tests/fixtures/shop/checkout.py +12 -0
- shikake-0.0.1/tests/fixtures/shop/member_shipping.py +11 -0
- shikake-0.0.1/tests/fixtures/shop/shipping.py +8 -0
- shikake-0.0.1/tests/fixtures/stock_workflow.py +42 -0
- shikake-0.0.1/tests/fixtures/value_expressions.py +10 -0
- shikake-0.0.1/tests/test_api_feedback_contracts.py +130 -0
- shikake-0.0.1/tests/test_api_usability_stage1.py +156 -0
- shikake-0.0.1/tests/test_api_usability_stage4.py +135 -0
- shikake-0.0.1/tests/test_assignment_structures_phase2.py +219 -0
- shikake-0.0.1/tests/test_ast_kind_correspondence.py +655 -0
- shikake-0.0.1/tests/test_async_modeling.py +261 -0
- shikake-0.0.1/tests/test_base_reference_contract.py +197 -0
- shikake-0.0.1/tests/test_binding_first_introduction.py +124 -0
- shikake-0.0.1/tests/test_binding_properties.py +308 -0
- shikake-0.0.1/tests/test_closed_spec_and_analysis_input.py +134 -0
- shikake-0.0.1/tests/test_compile_syntax_validation.py +169 -0
- shikake-0.0.1/tests/test_conditional_expression_bindings.py +104 -0
- shikake-0.0.1/tests/test_context_comprehensions_phase3.py +222 -0
- shikake-0.0.1/tests/test_control_flow.py +218 -0
- shikake-0.0.1/tests/test_deep_models.py +328 -0
- shikake-0.0.1/tests/test_deep_package_relations.py +155 -0
- shikake-0.0.1/tests/test_deep_remaining_expressions.py +143 -0
- shikake-0.0.1/tests/test_deep_statements.py +184 -0
- shikake-0.0.1/tests/test_doc_generator.py +115 -0
- shikake-0.0.1/tests/test_documentation_policy_canonical.py +118 -0
- shikake-0.0.1/tests/test_external_argument_diagnostics.py +123 -0
- shikake-0.0.1/tests/test_external_builder_stage3.py +217 -0
- shikake-0.0.1/tests/test_external_import_locations.py +132 -0
- shikake-0.0.1/tests/test_external_modeling.py +368 -0
- shikake-0.0.1/tests/test_function_class_forms.py +202 -0
- shikake-0.0.1/tests/test_generator_subject.py +240 -0
- shikake-0.0.1/tests/test_hierarchy_shared.py +66 -0
- shikake-0.0.1/tests/test_import_policy.py +405 -0
- shikake-0.0.1/tests/test_inspection.py +252 -0
- shikake-0.0.1/tests/test_inspection_diagnostic_repr.py +55 -0
- shikake-0.0.1/tests/test_kind_contract_experiment.py +166 -0
- shikake-0.0.1/tests/test_model_diagnostic_repr.py +97 -0
- shikake-0.0.1/tests/test_model_hash_cache.py +157 -0
- shikake-0.0.1/tests/test_modeling.py +269 -0
- shikake-0.0.1/tests/test_operations.py +211 -0
- shikake-0.0.1/tests/test_override_binding_order.py +169 -0
- shikake-0.0.1/tests/test_package.py +22 -0
- shikake-0.0.1/tests/test_package_diagnostic_repr.py +57 -0
- shikake-0.0.1/tests/test_package_extensions.py +197 -0
- shikake-0.0.1/tests/test_package_include_callback.py +233 -0
- shikake-0.0.1/tests/test_package_modeling.py +208 -0
- shikake-0.0.1/tests/test_package_relation_indexes.py +137 -0
- shikake-0.0.1/tests/test_partial_external_recovery_stage2.py +179 -0
- shikake-0.0.1/tests/test_public_api.py +63 -0
- shikake-0.0.1/tests/test_public_api_usage_examples.py +162 -0
- shikake-0.0.1/tests/test_public_documentation.py +170 -0
- shikake-0.0.1/tests/test_python314_syntax.py +262 -0
- shikake-0.0.1/tests/test_python315_modeling_rules.py +242 -0
- shikake-0.0.1/tests/test_readme_canonical.py +103 -0
- shikake-0.0.1/tests/test_reference_resolution_facts.py +496 -0
- shikake-0.0.1/tests/test_relation_analysis.py +207 -0
- shikake-0.0.1/tests/test_relation_fact_index.py +198 -0
- shikake-0.0.1/tests/test_remaining_forms.py +225 -0
- shikake-0.0.1/tests/test_scalar_model_identity.py +63 -0
- shikake-0.0.1/tests/test_scope_fact_boundaries.py +225 -0
- shikake-0.0.1/tests/test_shared_ast_facts.py +80 -0
- shikake-0.0.1/tests/test_shared_feedback_paths.py +174 -0
- shikake-0.0.1/tests/test_source_ingestion.py +350 -0
- shikake-0.0.1/tests/test_special_statements.py +184 -0
- shikake-0.0.1/tests/test_specification_migration_traceability.py +178 -0
- shikake-0.0.1/tests/test_specification_phase5_contracts.py +135 -0
- shikake-0.0.1/tests/test_specification_phase5_index_contracts.py +95 -0
- shikake-0.0.1/tests/test_specification_phase5_inspection_boundaries.py +112 -0
- shikake-0.0.1/tests/test_specification_phase6_references.py +89 -0
- shikake-0.0.1/tests/test_specification_sources.py +280 -0
- shikake-0.0.1/tests/test_structural_placements.py +257 -0
- shikake-0.0.1/tests/test_syntactic_binding_policy.py +113 -0
- shikake-0.0.1/tests/test_type_alias_unsupported.py +36 -0
- shikake-0.0.1/tests/test_type_parameters.py +187 -0
- shikake-0.0.1/tests/test_typed_accessors.py +68 -0
- shikake-0.0.1/tests/test_value_expressions_phase1.py +198 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# shikake changelog
|
|
2
|
+
|
|
3
|
+
This changelog summarizes user-facing changes by release. Design decisions and development history remain in Japanese canonical sources: [pre-release history](devdocs/canonical_sources/development_history/pre_release.py) and [performance refactoring history](devdocs/canonical_sources/development_history/performance.py).
|
|
4
|
+
|
|
5
|
+
## 0.0.1 - 2026-10-23
|
|
6
|
+
|
|
7
|
+
**Initial Alpha release.** The public API may change incompatibly in subsequent versions.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **AST-based modeling:** Kinds, Structures, Features, and role-based Models. Strict `parse_source()` / `parse_package()` and diagnostic Partial `inspect_source()` / `inspect_package()` APIs, plus bounded `format_model_tree()` output.
|
|
12
|
+
- **Input selection:** `extensions` and the `include` callback select files and directories for package analysis. Custom suffixes are permitted; their contents must still be parseable as Python AST. Regular `.py` files are the default.
|
|
13
|
+
- **Syntax validation:** Non-executing CPython compilation checks by default; `syntax_validation="ast"` skips the additional compilation check.
|
|
14
|
+
- **External definitions:** Trusted Shikumi declarations or `ExternalDefinitionsBuilder` can define external Kinds, Structures, and call mappings.
|
|
15
|
+
- **Import permissions:** Three `import_policy` modes and arbitrary absolute module names in `allowed_modules`, without runtime import resolution or sandbox guarantees.
|
|
16
|
+
- **Static information:** Base-class reference and override candidates, scoped `name_bindings`, and three binding dimensions. Neither definite assignment nor runtime name resolution is guaranteed.
|
|
17
|
+
|
|
18
|
+
### Python syntax support
|
|
19
|
+
|
|
20
|
+
- Models Python 3.12 `type` statements and generics, Python 3.13 type-parameter defaults, Python 3.14 t-strings and multiple-exception syntax, and Python 3.15 PEP 798 unpacking comprehensions.
|
|
21
|
+
- Dictionary-unpacking comprehensions use `model.value.comprehension.dict.unpacking`.
|
|
22
|
+
- Explicit Python 3.15 `lazy import` and `lazy from ... import` use the ordinary import Kinds and Structures with a `lazy` Feature on the import statement. Binding dimensions and static reference rules are unchanged; runtime lazy loading is not modeled.
|
|
23
|
+
- Python 3.13-and-earlier baseline rules and 3.14+ overlays are internal. No public model-version selection API is provided.
|
|
24
|
+
|
|
25
|
+
### Performance improvements
|
|
26
|
+
|
|
27
|
+
- **Structural Model hashes:** Model instances lazily cache their structural hashes. Hashing a parent also caches computed hashes for its descendants, reducing repeated traversal when those Models are subsequently reused. Structural equality, hash computation rules, and iterative traversal are preserved.
|
|
28
|
+
- **Relationship lookups:** `PackageModel.bindings_for()`, `bases_for()`, and `overrides_for()` use internal identity-based indexes rather than scanning every relationship on each call. Result contents, order, and the public API are unchanged.
|
|
29
|
+
- These internal optimizations trade some Model initialization, indexing, and hash-caching time and memory for faster repeated operations.
|
|
30
|
+
|
|
31
|
+
### Diagnostics and developer tooling
|
|
32
|
+
|
|
33
|
+
- **PackageModel diagnostics:** `repr(package)` provides a bounded summary of the composition Model, selected analyses, and counts of bindings, base references, and override candidates, without expanding each relationship fact. Use attributes and lookup methods for full information.
|
|
34
|
+
- **SourceInspection diagnostics:** `repr(inspection)` summarizes the Model and displays a name-binding count rather than expanding every binding. Both inspection result types keep complete `issues` content in their representations.
|
|
35
|
+
- **Documentation generator tests:** Expected argparse errors are captured and asserted in invalid-input tests, keeping test output clean. CLI error messages are unchanged.
|
|
36
|
+
|
|
37
|
+
### Publication and compatibility notes
|
|
38
|
+
|
|
39
|
+
- The distribution and public import name is **`shikake`**. No compatibility import under the former development name `kangen` is provided.
|
|
40
|
+
- The Japanese canonical sources are authoritative. See the [API Reference](docs/api_reference/INDEX.md) and [Status](docs/STATUS.md) for the current contracts, limitations, and separately recorded interpreter test evidence.
|
|
41
|
+
- Consult the actual PyPI distribution or GitHub release for downloadable artifacts and publication status.
|
shikake-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 minoru-jp
|
|
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,18 @@
|
|
|
1
|
+
# Keep the source distribution self-contained for tests and canonical source editing.
|
|
2
|
+
include Makefile
|
|
3
|
+
include README.md
|
|
4
|
+
include CHANGELOG.md
|
|
5
|
+
graft docs
|
|
6
|
+
graft tests
|
|
7
|
+
graft devdocs
|
|
8
|
+
prune devdocs/canonical_documents
|
|
9
|
+
|
|
10
|
+
# Exclude generated caches and temporary files from the source archive.
|
|
11
|
+
prune .pytest_cache
|
|
12
|
+
prune .ruff_cache
|
|
13
|
+
prune .basedpyright
|
|
14
|
+
prune .pyright
|
|
15
|
+
prune build
|
|
16
|
+
prune dist
|
|
17
|
+
global-exclude *.py[cod]
|
|
18
|
+
global-exclude .DS_Store CACHEDIR.TAG
|
shikake-0.0.1/Makefile
ADDED
shikake-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: shikake
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Experimental AST-based Python source modeling library
|
|
5
|
+
Author: minoru-jp
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/minoru-jp/shikake
|
|
8
|
+
Project-URL: Repository, https://github.com/minoru-jp/shikake
|
|
9
|
+
Project-URL: Documentation, https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md
|
|
10
|
+
Keywords: python-ast,static-analysis,source-modeling,transpilation,restricted-python
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: shikumi<2.0.0,>=0.2.4
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: shikumi-devdoc==0.3.5; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff==0.16.10; extra == "dev"
|
|
26
|
+
Requires-Dist: basedpyright==1.40.1; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# shikake
|
|
30
|
+
|
|
31
|
+
**shikake** is an AST-based library that models the static structures and relationships of Python source code according to consumer-defined, domain-specific structural conventions.
|
|
32
|
+
|
|
33
|
+
It provides building blocks for working with Python code under your own rules, including transpilation and the design or validation of restricted Python dialects. You can also define custom structures and have designated Python constructs modeled using those structures.
|
|
34
|
+
|
|
35
|
+
Python syntax validation defaults to CPython's non-executing compilation level (`syntax_validation="compile"`). Use `syntax_validation="ast"` to skip compilation checks when modeling AST-parseable restricted dialects; unsupported shikake syntax remains unsupported. This does not execute input code or guarantee runtime correctness.
|
|
36
|
+
|
|
37
|
+
## Development status (Alpha)
|
|
38
|
+
|
|
39
|
+
shikake is currently in **Alpha**. Public APIs, specifications, and data structures may change incompatibly without prior notice. See [STATUS](https://github.com/minoru-jp/shikake/blob/HEAD/docs/STATUS.md) for current progress.
|
|
40
|
+
|
|
41
|
+
## Core concepts
|
|
42
|
+
|
|
43
|
+
Rather than preserving Python syntax verbatim, shikake represents selected syntactic information in a form that consumers can interpret for their own purposes.
|
|
44
|
+
|
|
45
|
+
### Model structure
|
|
46
|
+
|
|
47
|
+
- **Kind** classifies a syntactic element.
|
|
48
|
+
- **Structure** specifies the roles and shapes of its constituent parts.
|
|
49
|
+
- **Feature** captures orthogonal characteristics, such as `async` or an explicitly written `lazy` import modifier.
|
|
50
|
+
- **Model** holds a concrete element according to these definitions.
|
|
51
|
+
|
|
52
|
+
Trusted external Shikumi declarations or an `ExternalDefinitionsBuilder` using Python data can add Kinds and Structures, and registered calls are represented by dedicated Models during parsing. External Feature declarations are not currently supported.
|
|
53
|
+
|
|
54
|
+
### Three dimensions of name binding
|
|
55
|
+
|
|
56
|
+
shikake represents three independent properties of a name's binding:
|
|
57
|
+
|
|
58
|
+
- `introduction`: whether the introduction is structurally stable (`stable` or `unstable`).
|
|
59
|
+
- `may_rebind`: whether a name may be rebound by a later or repeatable write, or by an augmented assignment.
|
|
60
|
+
- `may_delete`: whether the syntax indicates possible deletion.
|
|
61
|
+
|
|
62
|
+
For example, `x = 1` alone has `may_rebind=False`; adding `x = 2` makes it `True`. A lone `n += 1` does not establish a stable introduction. These are **syntactic facts**, not predictions of execution, definite assignment, or judgments about code quality.
|
|
63
|
+
|
|
64
|
+
### Static relationship candidates
|
|
65
|
+
|
|
66
|
+
shikake can report candidate targets of base-class references and same-name method override candidates. These are candidates supported by the AST, not guarantees about runtime targets or method resolution order. See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for the available results and links to their specifications.
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
Python 3.11 or later is required. CI targets Python 3.11–3.15; Python 3.14 t-strings are modeled as distinct Kinds.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m pip install shikake
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick start
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import shikake
|
|
80
|
+
|
|
81
|
+
source = '''
|
|
82
|
+
class Counter:
|
|
83
|
+
def __init__(self, start=0):
|
|
84
|
+
self.value = start
|
|
85
|
+
|
|
86
|
+
def increase(self, amount):
|
|
87
|
+
if amount > 0:
|
|
88
|
+
self.value += amount
|
|
89
|
+
return self.value
|
|
90
|
+
|
|
91
|
+
def calculate(values):
|
|
92
|
+
counter = Counter()
|
|
93
|
+
for value in values:
|
|
94
|
+
counter.increase(value)
|
|
95
|
+
return counter.value
|
|
96
|
+
'''
|
|
97
|
+
|
|
98
|
+
root = shikake.parse_source(source)
|
|
99
|
+
|
|
100
|
+
for model in root.walk():
|
|
101
|
+
print(model.kind.id)
|
|
102
|
+
print([part.role for part in model.parts()])
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`parse_source()` builds a Model from one Python source string, and `walk()` traverses its composition tree. Kind, Structure, and Feature let consumers classify elements without depending directly on their original AST nodes.
|
|
106
|
+
|
|
107
|
+
### Strict and Partial analysis
|
|
108
|
+
|
|
109
|
+
- **Strict:** `parse_source()` and `parse_package()` require a complete result and raise on unsupported syntax or invalid structures.
|
|
110
|
+
- **Partial:** `inspect_source()` and `inspect_package()` return available results together with diagnostics when full analysis is not possible.
|
|
111
|
+
|
|
112
|
+
Use Strict analysis when completeness is required, and Partial analysis to inspect unsupported or incomplete inputs. **An incomplete Partial result must not be treated as a fully analyzed input.** Consult the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for details.
|
|
113
|
+
|
|
114
|
+
For package analysis, pass an `include(path, is_directory)` callback to `parse_package()` or `inspect_package()` to choose subdirectories and matching source files. Returning `False` for a directory prunes that entire subtree. The `extensions=(".py",)` parameter selects source suffixes: `(".dot",)` chooses only `.dot` and `(".py", ".dot")` chooses both. These files must contain Python syntax. By default **all** regular `.py` files are included, including those under `.venv`; shikake does not impose exclusion patterns. See [Package input selection](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/public.md#package-input-extensions-extensions-and-selection-include).
|
|
115
|
+
|
|
116
|
+
### Optional import permissions
|
|
117
|
+
|
|
118
|
+
Each parsing/inspection API supports `import_policy="unrestricted"` (default), `"registered_interfaces"` (only explicitly imported registered interfaces), and `"registered_modules"` (registered external modules plus caller-specified `allowed_modules=("math", "custom_tools")`). `registered_modules` also permits every explicit registered-interface import. Both restricted modes admit the single directive `from __future__ import annotations`. Relative imports, including within the analyzed package, remain forbidden: change them to absolute imports and explicitly allow the written module names as needed. `allowed_modules` names must be NFKC-normalized. These checks compare written absolute module names without importing them and do not provide a security sandbox. See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/public.md#caller-selected-import-restrictions-import_policy-allowed_modules).
|
|
119
|
+
|
|
120
|
+
## External structures
|
|
121
|
+
|
|
122
|
+
Consumers can define custom Kinds and Structures with trusted Shikumi declarations or `shikake.external.ExternalDefinitionsBuilder` and provide them to the parser. For example, a transpiler may map a Python-facing memory or I/O interface to special operations in its target language.
|
|
123
|
+
|
|
124
|
+
When their documented conditions are met, explicitly imported calls registered as external operations produce dedicated Models instead of ordinary Python call Models. This is not general-purpose resolution of arbitrary libraries: explicit-import and reserved-name rules constrain recognition. See the [External Definitions API](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/external.md).
|
|
125
|
+
|
|
126
|
+
## Using analysis results
|
|
127
|
+
|
|
128
|
+
Transpilation and restricted-Python validation share a basic pattern: inspect Kind, Structure, and Feature information, optionally consult binding facts and static relationship candidates, and then **apply the consumer's own rules** to translate or accept/reject the input.
|
|
129
|
+
|
|
130
|
+
shikake does not define those downstream rules. Models are intended to be obtained from the official parsing APIs; constructing your own Models is unsupported.
|
|
131
|
+
|
|
132
|
+
## Limitations
|
|
133
|
+
|
|
134
|
+
shikake does not execute source code, evaluate values, infer types, or resolve dynamic names. Models do not aim to reproduce the original Python code perfectly or to establish its runtime semantics. Syntactic inspection alone does not provide a secure execution sandbox.
|
|
135
|
+
|
|
136
|
+
See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for individual contracts and the [Documentation Policy](https://github.com/minoru-jp/shikake/blob/HEAD/docs/DOCUMENTATION_POLICY.md) for how the sources are managed.
|
|
137
|
+
|
|
138
|
+
## Documentation
|
|
139
|
+
|
|
140
|
+
[API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) | [Status](https://github.com/minoru-jp/shikake/blob/HEAD/docs/STATUS.md) | [Changelog](https://github.com/minoru-jp/shikake/blob/HEAD/CHANGELOG.md) | [Documentation Policy](https://github.com/minoru-jp/shikake/blob/HEAD/docs/DOCUMENTATION_POLICY.md)
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
shikake is distributed under the [MIT License](https://github.com/minoru-jp/shikake/blob/HEAD/LICENSE).
|
shikake-0.0.1/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# shikake
|
|
2
|
+
|
|
3
|
+
**shikake** is an AST-based library that models the static structures and relationships of Python source code according to consumer-defined, domain-specific structural conventions.
|
|
4
|
+
|
|
5
|
+
It provides building blocks for working with Python code under your own rules, including transpilation and the design or validation of restricted Python dialects. You can also define custom structures and have designated Python constructs modeled using those structures.
|
|
6
|
+
|
|
7
|
+
Python syntax validation defaults to CPython's non-executing compilation level (`syntax_validation="compile"`). Use `syntax_validation="ast"` to skip compilation checks when modeling AST-parseable restricted dialects; unsupported shikake syntax remains unsupported. This does not execute input code or guarantee runtime correctness.
|
|
8
|
+
|
|
9
|
+
## Development status (Alpha)
|
|
10
|
+
|
|
11
|
+
shikake is currently in **Alpha**. Public APIs, specifications, and data structures may change incompatibly without prior notice. See [STATUS](https://github.com/minoru-jp/shikake/blob/HEAD/docs/STATUS.md) for current progress.
|
|
12
|
+
|
|
13
|
+
## Core concepts
|
|
14
|
+
|
|
15
|
+
Rather than preserving Python syntax verbatim, shikake represents selected syntactic information in a form that consumers can interpret for their own purposes.
|
|
16
|
+
|
|
17
|
+
### Model structure
|
|
18
|
+
|
|
19
|
+
- **Kind** classifies a syntactic element.
|
|
20
|
+
- **Structure** specifies the roles and shapes of its constituent parts.
|
|
21
|
+
- **Feature** captures orthogonal characteristics, such as `async` or an explicitly written `lazy` import modifier.
|
|
22
|
+
- **Model** holds a concrete element according to these definitions.
|
|
23
|
+
|
|
24
|
+
Trusted external Shikumi declarations or an `ExternalDefinitionsBuilder` using Python data can add Kinds and Structures, and registered calls are represented by dedicated Models during parsing. External Feature declarations are not currently supported.
|
|
25
|
+
|
|
26
|
+
### Three dimensions of name binding
|
|
27
|
+
|
|
28
|
+
shikake represents three independent properties of a name's binding:
|
|
29
|
+
|
|
30
|
+
- `introduction`: whether the introduction is structurally stable (`stable` or `unstable`).
|
|
31
|
+
- `may_rebind`: whether a name may be rebound by a later or repeatable write, or by an augmented assignment.
|
|
32
|
+
- `may_delete`: whether the syntax indicates possible deletion.
|
|
33
|
+
|
|
34
|
+
For example, `x = 1` alone has `may_rebind=False`; adding `x = 2` makes it `True`. A lone `n += 1` does not establish a stable introduction. These are **syntactic facts**, not predictions of execution, definite assignment, or judgments about code quality.
|
|
35
|
+
|
|
36
|
+
### Static relationship candidates
|
|
37
|
+
|
|
38
|
+
shikake can report candidate targets of base-class references and same-name method override candidates. These are candidates supported by the AST, not guarantees about runtime targets or method resolution order. See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for the available results and links to their specifications.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
Python 3.11 or later is required. CI targets Python 3.11–3.15; Python 3.14 t-strings are modeled as distinct Kinds.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
python -m pip install shikake
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import shikake
|
|
52
|
+
|
|
53
|
+
source = '''
|
|
54
|
+
class Counter:
|
|
55
|
+
def __init__(self, start=0):
|
|
56
|
+
self.value = start
|
|
57
|
+
|
|
58
|
+
def increase(self, amount):
|
|
59
|
+
if amount > 0:
|
|
60
|
+
self.value += amount
|
|
61
|
+
return self.value
|
|
62
|
+
|
|
63
|
+
def calculate(values):
|
|
64
|
+
counter = Counter()
|
|
65
|
+
for value in values:
|
|
66
|
+
counter.increase(value)
|
|
67
|
+
return counter.value
|
|
68
|
+
'''
|
|
69
|
+
|
|
70
|
+
root = shikake.parse_source(source)
|
|
71
|
+
|
|
72
|
+
for model in root.walk():
|
|
73
|
+
print(model.kind.id)
|
|
74
|
+
print([part.role for part in model.parts()])
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`parse_source()` builds a Model from one Python source string, and `walk()` traverses its composition tree. Kind, Structure, and Feature let consumers classify elements without depending directly on their original AST nodes.
|
|
78
|
+
|
|
79
|
+
### Strict and Partial analysis
|
|
80
|
+
|
|
81
|
+
- **Strict:** `parse_source()` and `parse_package()` require a complete result and raise on unsupported syntax or invalid structures.
|
|
82
|
+
- **Partial:** `inspect_source()` and `inspect_package()` return available results together with diagnostics when full analysis is not possible.
|
|
83
|
+
|
|
84
|
+
Use Strict analysis when completeness is required, and Partial analysis to inspect unsupported or incomplete inputs. **An incomplete Partial result must not be treated as a fully analyzed input.** Consult the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for details.
|
|
85
|
+
|
|
86
|
+
For package analysis, pass an `include(path, is_directory)` callback to `parse_package()` or `inspect_package()` to choose subdirectories and matching source files. Returning `False` for a directory prunes that entire subtree. The `extensions=(".py",)` parameter selects source suffixes: `(".dot",)` chooses only `.dot` and `(".py", ".dot")` chooses both. These files must contain Python syntax. By default **all** regular `.py` files are included, including those under `.venv`; shikake does not impose exclusion patterns. See [Package input selection](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/public.md#package-input-extensions-extensions-and-selection-include).
|
|
87
|
+
|
|
88
|
+
### Optional import permissions
|
|
89
|
+
|
|
90
|
+
Each parsing/inspection API supports `import_policy="unrestricted"` (default), `"registered_interfaces"` (only explicitly imported registered interfaces), and `"registered_modules"` (registered external modules plus caller-specified `allowed_modules=("math", "custom_tools")`). `registered_modules` also permits every explicit registered-interface import. Both restricted modes admit the single directive `from __future__ import annotations`. Relative imports, including within the analyzed package, remain forbidden: change them to absolute imports and explicitly allow the written module names as needed. `allowed_modules` names must be NFKC-normalized. These checks compare written absolute module names without importing them and do not provide a security sandbox. See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/public.md#caller-selected-import-restrictions-import_policy-allowed_modules).
|
|
91
|
+
|
|
92
|
+
## External structures
|
|
93
|
+
|
|
94
|
+
Consumers can define custom Kinds and Structures with trusted Shikumi declarations or `shikake.external.ExternalDefinitionsBuilder` and provide them to the parser. For example, a transpiler may map a Python-facing memory or I/O interface to special operations in its target language.
|
|
95
|
+
|
|
96
|
+
When their documented conditions are met, explicitly imported calls registered as external operations produce dedicated Models instead of ordinary Python call Models. This is not general-purpose resolution of arbitrary libraries: explicit-import and reserved-name rules constrain recognition. See the [External Definitions API](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/external.md).
|
|
97
|
+
|
|
98
|
+
## Using analysis results
|
|
99
|
+
|
|
100
|
+
Transpilation and restricted-Python validation share a basic pattern: inspect Kind, Structure, and Feature information, optionally consult binding facts and static relationship candidates, and then **apply the consumer's own rules** to translate or accept/reject the input.
|
|
101
|
+
|
|
102
|
+
shikake does not define those downstream rules. Models are intended to be obtained from the official parsing APIs; constructing your own Models is unsupported.
|
|
103
|
+
|
|
104
|
+
## Limitations
|
|
105
|
+
|
|
106
|
+
shikake does not execute source code, evaluate values, infer types, or resolve dynamic names. Models do not aim to reproduce the original Python code perfectly or to establish its runtime semantics. Syntactic inspection alone does not provide a secure execution sandbox.
|
|
107
|
+
|
|
108
|
+
See the [API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) for individual contracts and the [Documentation Policy](https://github.com/minoru-jp/shikake/blob/HEAD/docs/DOCUMENTATION_POLICY.md) for how the sources are managed.
|
|
109
|
+
|
|
110
|
+
## Documentation
|
|
111
|
+
|
|
112
|
+
[API Reference](https://github.com/minoru-jp/shikake/blob/HEAD/docs/api_reference/INDEX.md) | [Status](https://github.com/minoru-jp/shikake/blob/HEAD/docs/STATUS.md) | [Changelog](https://github.com/minoru-jp/shikake/blob/HEAD/CHANGELOG.md) | [Documentation Policy](https://github.com/minoru-jp/shikake/blob/HEAD/docs/DOCUMENTATION_POLICY.md)
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
shikake is distributed under the [MIT License](https://github.com/minoru-jp/shikake/blob/HEAD/LICENSE).
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Derive the English API index from the two published API translations.
|
|
2
|
+
|
|
3
|
+
The index is navigation, not a separate canonical document. To change an API
|
|
4
|
+
contract, edit its Japanese canonical source and republish its translation first.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import re
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
14
|
+
API_DOCS = ROOT / "docs" / "api_reference"
|
|
15
|
+
API_HEADING = re.compile(r"^## (API_\d{3}): `([^`]+)`$", re.MULTILINE)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def render_index(directory: Path = API_DOCS) -> str:
|
|
19
|
+
sections = [
|
|
20
|
+
"# API Reference",
|
|
21
|
+
"",
|
|
22
|
+
(
|
|
23
|
+
"Public API documentation translated from Japanese canonical sources. "
|
|
24
|
+
"Specification links in these pages lead directly to the Japanese Python source modules."
|
|
25
|
+
),
|
|
26
|
+
"",
|
|
27
|
+
(
|
|
28
|
+
"See the [README](../../README.md), [STATUS](../STATUS.md), and "
|
|
29
|
+
"[Documentation Policy](../DOCUMENTATION_POLICY.md)."
|
|
30
|
+
),
|
|
31
|
+
"",
|
|
32
|
+
(
|
|
33
|
+
"Usage topics: [Relationship analysis selection]"
|
|
34
|
+
"(public.md#relationship-analysis-selection-analyses) and "
|
|
35
|
+
"[minimal external definition example]"
|
|
36
|
+
"(external.md#minimal-working-example)."
|
|
37
|
+
),
|
|
38
|
+
"",
|
|
39
|
+
]
|
|
40
|
+
for filename, heading in (
|
|
41
|
+
("public.md", "Core Python API"),
|
|
42
|
+
("external.md", "External Definitions API"),
|
|
43
|
+
):
|
|
44
|
+
content = (directory / filename).read_text(encoding="utf-8")
|
|
45
|
+
names = API_HEADING.findall(content)
|
|
46
|
+
if not names:
|
|
47
|
+
raise ValueError(f"no API entries in {filename}")
|
|
48
|
+
sections.extend((f"## {heading}", ""))
|
|
49
|
+
for identifier, name in names:
|
|
50
|
+
suffix = re.sub(r"[^a-z0-9_-]", "", name.lower())
|
|
51
|
+
anchor = identifier.lower() + "-" + suffix
|
|
52
|
+
sections.append(f"- [{identifier}: `{name}`]({filename}#{anchor})")
|
|
53
|
+
sections.append("")
|
|
54
|
+
return "\n".join(sections)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def main() -> int:
|
|
58
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
59
|
+
parser.add_argument(
|
|
60
|
+
"--check", action="store_true", help="verify the current index without writing"
|
|
61
|
+
)
|
|
62
|
+
args = parser.parse_args()
|
|
63
|
+
expected = render_index()
|
|
64
|
+
path = API_DOCS / "INDEX.md"
|
|
65
|
+
if args.check:
|
|
66
|
+
if not path.exists() or path.read_text(encoding="utf-8") != expected:
|
|
67
|
+
parser.error(
|
|
68
|
+
"API index is outdated: regenerate from the published API pages"
|
|
69
|
+
)
|
|
70
|
+
else:
|
|
71
|
+
path.write_text(expected, encoding="utf-8")
|
|
72
|
+
return 0
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
raise SystemExit(main())
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""shikakeの公開Python APIの正本参照。"""
|