-
Notifications
You must be signed in to change notification settings - Fork 644
Fix/hash pattern scope #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix/hash pattern scope #718
Conversation
…with enhanced data processing and visualization features. Updated preswald.toml to reflect new project title and logging configuration. Added sidebar filters for sales and segment selection, and implemented multiple visualizations including sales by category, profit margin by region, and total sales by state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've added some comments to be addressed. Additionally, in the future, could you split the PR into 2 - one for the example, and one for feature work?
def __init__(self): | ||
self._state_cache: dict[str, str] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to rename _state_cache and add a dirty set?
|
||
import msgpack | ||
import numpy as np | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# Compiled regex pattern for matching SHA-256 hashes | ||
HASH_PATTERN = re.compile(r"^[0-9a-f]{64}$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not calling HASH_PATTERN outside RenderBuffer, so we don't need to expose it here.
@@ -4,14 +4,17 @@ | |||
import re | |||
import zlib | |||
from datetime import date, datetime | |||
from typing import Any | |||
from typing import Any, Dict, List, Optional, Set, Tuple, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the latest version of ruff operating on python 3.10, it seems the preferred way is to use things like dict
instead of Dict
and |
instead of Optional
. So we don't need these
@coreyalejandro were there specific errors you encountered around the HASH_PATTERN? |
Hey Shivam, thanks for the review! Here’s the Q&A with code snippets:
-from typing import Dict, Optional
-
-_state_cache: Dict[str, str]
+_state_cache: dict[str, str]
class RenderBuffer:
# before: hidden inside class
# HASH_PATTERN = re.compile(r"...")
# after: available at module level
HASH_PATTERN = re.compile(r"...")
-from typing import Dict, Optional, Any
-
-def foo(x: Optional[Any]) -> Dict[str, Any]:
+def foo(x: Any | None) -> dict[str, Any]:
from preswald.engine.utils import HASH_PATTERN # crashed before Moving it out fixes the import.
dirty_set = set()
def mark_dirty(item):
dirty_set.add(item) You use it to track what needs cleaning up. I’ve created the demo/example PR and will submit it later this morning after adding some updates to the request and project. Let me know if there’s anything else you need on this project or any other. — Corey |
name: Pull Request
about: Create a pull request to contribute to the project
title: fix: Move HASH_PATTERN to module level for better accessibility
labels: ''
assignees: ''
Related Issue
Fixes an accessibility issue where HASH_PATTERN was not available outside RenderBuffer, causing NameErrors when accessed at module level.
Description of Changes
This PR fixes an issue where
HASH_PATTERN
was not accessible outside theRenderBuffer
class, which could cause NameErrors when trying to use it from other parts of the codebase.Changes made:
HASH_PATTERN
regex pattern to module levelRenderBuffer
class to use the module-level patternThis change maintains the same functionality while making the pattern more accessible and reusable across the codebase.
Type of Change
Testing
I tested the changes by:
HASH_PATTERN
is accessible at the module level:RenderBuffer
class continues to work as expected:No new tests were needed as this is a refactoring that maintains existing functionality while improving accessibility.
Checklist