diff --git a/make_sync.py b/make_sync.py index 779e37ee..94c585d4 100644 --- a/make_sync.py +++ b/make_sync.py @@ -17,6 +17,8 @@ "AsyncMock": "Mock", # RedisVL uses SearchIndex for sync, not SyncSearchIndex "AsyncSearchIndex": "SearchIndex", + # Fix supports_hash_field_expiration to check sync Redis class + "redis_lib.asyncio.Redis": "redis_lib.Redis", } @@ -75,39 +77,39 @@ def main(): "redis_om/model/cli/migrate_data.py", "redis_om/model/cli/migrate.py" ] - + for cli_file in cli_files: file_path = Path(__file__).absolute().parent / cli_file if file_path.exists(): with open(file_path, 'r') as f: content = f.read() - + # Remove run_async() call wrappers (not the function definition) # Only match run_async() calls that are not function definitions def remove_run_async_call(match): inner_content = match.group(1) return inner_content - + # Pattern to match run_async() function calls (not definitions) # Look for = or return statements followed by run_async(...) lines = content.split('\n') new_lines = [] - + for line in lines: # Skip function definitions if 'def run_async(' in line: new_lines.append(line) continue - + # Replace run_async() calls if 'run_async(' in line and ('=' in line or 'return ' in line or line.strip().startswith('run_async(')): # Simple pattern for function calls line = re.sub(r'run_async\(([^)]+(?:\([^)]*\)[^)]*)*)\)', r'\1', line) - + new_lines.append(line) - + content = '\n'.join(new_lines) - + with open(file_path, 'w') as f: f.write(content) @@ -117,6 +119,13 @@ def remove_run_async_call(match): with open(model_file, 'r') as f: content = f.read() + # Fix supports_hash_field_expiration to check sync Redis class + # The unasync replacement doesn't work for dotted attribute access + content = content.replace( + 'redis_lib.asyncio.Redis', + 'redis_lib.Redis' + ) + # Fix Pipeline import: redis.asyncio.client -> redis.client content = content.replace( 'from redis.asyncio.client import Pipeline', diff --git a/pyproject.toml b/pyproject.toml index 8dfac88d..a1578743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "redis-om" -version = "1.0.5" +version = "1.0.6" description = "Object mappings, and more, for Redis." authors = [{ name = "Redis OSS", email = "oss@redis.com" }] maintainers = [{ name = "Redis OSS", email = "oss@redis.com" }] @@ -81,12 +81,23 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["aredis_om", "redis_om"] +# Include generated sync code (redis_om/) that is in .gitignore +# These files are created by `make sync` before building +artifacts = [ + "redis_om/**/*", + "tests_sync/**/*", +] [tool.hatch.build.targets.sdist] include = [ "aredis_om/**/*", "redis_om/**/*", ] +# Include generated sync code (redis_om/) that is in .gitignore +artifacts = [ + "redis_om/**/*", + "tests_sync/**/*", +]