ethspecify 0.3.4__tar.gz → 0.3.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -3,7 +3,7 @@ import json
3
3
  import os
4
4
  import sys
5
5
 
6
- from .core import grep, replace_spec_tags, get_pyspec, get_latest_fork, get_spec_item_history, load_config, run_checks, sort_specref_yaml, generate_specref_files, get_yaml_filename_for_spec_attr, get_spec_attr_and_name, add_missing_entries_to_yaml
6
+ from .core import grep, replace_spec_tags, get_pyspec, get_spec_item_history, load_config, run_checks, sort_specref_yaml, generate_specref_files
7
7
 
8
8
 
9
9
  def process(args):
@@ -11,7 +11,7 @@ import tokenize
11
11
  import yaml
12
12
 
13
13
 
14
- def validate_exception_items(exceptions, version):
14
+ def validate_exception_items(exceptions, version, require_exceptions_have_fork=False):
15
15
  """
16
16
  Validate that exception items actually exist in the spec.
17
17
  Raises an exception if any item doesn't exist.
@@ -69,6 +69,9 @@ def validate_exception_items(exceptions, version):
69
69
  # If no fork specified, we'll check if it exists in any fork
70
70
  item_name = item
71
71
  fork = None
72
+ if require_exceptions_have_fork:
73
+ errors.append(f"invalid key: {exception_key}.{item_name} (missing fork)")
74
+ continue
72
75
 
73
76
  # Check if the item exists
74
77
  item_found = False
@@ -116,14 +119,19 @@ def load_config(directory=None):
116
119
  # Get version from config, default to 'nightly'
117
120
  version = config.get('version', 'nightly')
118
121
 
122
+ specrefs_require = False
123
+ if 'specrefs' in config and isinstance(config['specrefs'], dict):
124
+ specrefs_require = config['specrefs'].get('require_exceptions_have_fork', False)
125
+ require_exceptions_have_fork = config.get('require_exceptions_have_fork', False) or specrefs_require
126
+
119
127
  # Validate exceptions in root config
120
128
  if 'exceptions' in config:
121
- validate_exception_items(config['exceptions'], version)
129
+ validate_exception_items(config['exceptions'], version, require_exceptions_have_fork)
122
130
 
123
131
  # Also validate exceptions in specrefs section if present
124
132
  if 'specrefs' in config and isinstance(config['specrefs'], dict):
125
133
  if 'exceptions' in config['specrefs']:
126
- validate_exception_items(config['specrefs']['exceptions'], version)
134
+ validate_exception_items(config['specrefs']['exceptions'], version, require_exceptions_have_fork)
127
135
 
128
136
  return config
129
137
  except (yaml.YAMLError, IOError) as e:
@@ -1798,6 +1806,31 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
1798
1806
  """
1799
1807
  version = config.get('version', 'nightly')
1800
1808
  preset = 'mainnet' # Could make this configurable
1809
+ specrefs_config = config.get('specrefs', {})
1810
+
1811
+ # Resolve exceptions (support root or specrefs section, but not both)
1812
+ if isinstance(specrefs_config, list):
1813
+ exceptions = config.get('exceptions', {})
1814
+ else:
1815
+ specrefs_exceptions = specrefs_config.get('exceptions', {})
1816
+ root_exceptions = config.get('exceptions', {})
1817
+ if specrefs_exceptions and root_exceptions:
1818
+ print("Warning: Exceptions found in both root and specrefs sections. Using specrefs exceptions.")
1819
+ exceptions = specrefs_exceptions
1820
+ elif specrefs_exceptions:
1821
+ exceptions = specrefs_exceptions
1822
+ else:
1823
+ exceptions = root_exceptions
1824
+
1825
+ category_exception_keys = {
1826
+ 'ssz_objects': ['ssz_objects', 'ssz_object', 'containers', 'container'],
1827
+ 'config_vars': ['configs', 'config_variables', 'config_var'],
1828
+ 'preset_vars': ['presets', 'preset_variables', 'preset_var'],
1829
+ 'dataclasses': ['dataclasses', 'dataclass'],
1830
+ 'functions': ['functions', 'fn'],
1831
+ 'constant_vars': ['constants', 'constant_variables', 'constant_var'],
1832
+ 'custom_types': ['custom_types', 'custom_type']
1833
+ }
1801
1834
 
1802
1835
  # Get all spec items
1803
1836
  pyspec = get_pyspec(version)
@@ -1830,6 +1863,14 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
1830
1863
  continue
1831
1864
 
1832
1865
  category, spec_attr = filename_to_category[yaml_basename]
1866
+ type_exceptions = []
1867
+ if isinstance(exceptions, dict) and category in category_exception_keys:
1868
+ for key in category_exception_keys[category]:
1869
+ if key in exceptions:
1870
+ type_exceptions = exceptions[key]
1871
+ break
1872
+ if type_exceptions and not isinstance(type_exceptions, list):
1873
+ type_exceptions = [type_exceptions]
1833
1874
 
1834
1875
  # Collect all items in this category organized by name and fork
1835
1876
  items_by_name = {}
@@ -1885,6 +1926,17 @@ def add_missing_spec_items_to_yaml_files(project_dir, config, specrefs_files):
1885
1926
  versions.append((fork, item_data, spec_content))
1886
1927
  prev_content = spec_content
1887
1928
 
1929
+ # Skip versions that are excepted for this item
1930
+ if type_exceptions:
1931
+ versions = [
1932
+ (fork, item_data, spec_content)
1933
+ for fork, item_data, spec_content in versions
1934
+ if not is_excepted(item_name, fork, type_exceptions)
1935
+ ]
1936
+
1937
+ if not versions:
1938
+ continue
1939
+
1888
1940
  # Create entries based on number of unique versions
1889
1941
  use_fork_suffix = len(versions) > 1
1890
1942
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ethspecify
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: A utility for processing Ethereum specification tags.
5
5
  Home-page: https://github.com/jtraglia/ethspecify
6
6
  Author: Justin Traglia
@@ -8,7 +8,7 @@ long_description = (this_directory / "README.md").read_text(encoding="utf-8")
8
8
 
9
9
  setup(
10
10
  name="ethspecify",
11
- version="0.3.4",
11
+ version="0.3.5",
12
12
  description="A utility for processing Ethereum specification tags.",
13
13
  long_description=long_description,
14
14
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes