Skip to content

String Reading and Path Typing #35

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

Merged
merged 4 commits into from
May 13, 2024
Merged

String Reading and Path Typing #35

merged 4 commits into from
May 13, 2024

Conversation

H00N24
Copy link
Collaborator

@H00N24 H00N24 commented May 9, 2024

Hi in this PR I would like to add some functionality to the Python wrapper:

  • parse_string function that can parse already loaded string as in the cloud setup we're loading this file from zip in S3 thus we already have it in memory
  • adds Union[str | Pathlike] typing to parse to allow str paths for mypy type-checking + mypy CI check
  • (optional) nix & direnv setup for local dev. For users using these tools it automatically builds an environment will all dev dependencies.

I've built it on top of the other PR just so I could pass the Rust cargo test exception, we can rebase it on top of the master if we decide to change the previous PR.

@H00N24 H00N24 requested a review from pickx May 9, 2024 08:54
@H00N24 H00N24 force-pushed the ondrej/string-reading branch from 8cb42a7 to cae9620 Compare May 9, 2024 08:58
Copy link
Collaborator

@pickx pickx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't say I have any experience with nix but not much to complain about here.

let elements = Builder::new(&src).build().map_err(|_| {
let display = path.display();
let desc = format!("failed to parse source file: {display}");
let desc = String::from("failed to parse source code");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, can be reduced to

.map_err(|_| PyRuntimeError::new_err("failed to parse source code"))?;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

.envrc Outdated
Comment on lines 1 to 6
if command -v nix &>/dev/null; then
# Load .envrc from certora dir if exists
[ -f ../.envrc ] && source_env ..
# Use nix if it's available
use flake
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so to be clear, what's the behavior if nix is unavailable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the nix is not available direnv will only create a virtual environment using the stdlib venv package and activate the virtual environment.

Comment on lines +29 to +32
p = map(as_list, [p_file, p_file_as_string, p_from_string])
assert all(
x == y for x in p for y in p
), "all three parsers should parse the same elements"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Base automatically changed from ondrej/aws-pypi-build to master May 10, 2024 06:26
@H00N24 H00N24 force-pushed the ondrej/string-reading branch from cae9620 to dfc7ee3 Compare May 10, 2024 06:30
@H00N24 H00N24 requested a review from pickx May 10, 2024 06:44
@H00N24 H00N24 merged commit d34e992 into master May 13, 2024
4 checks passed
@H00N24 H00N24 deleted the ondrej/string-reading branch May 13, 2024 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants