Skip to content
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

Isn't version a str? #311

Open
DimitriPapadopoulos opened this issue Sep 28, 2023 · 2 comments
Open

Isn't version a str? #311

DimitriPapadopoulos opened this issue Sep 28, 2023 · 2 comments

Comments

@DimitriPapadopoulos
Copy link
Contributor

In the following code, the type hint for version is str. Yet, the code has been modified to handle floats too (#189).

Should the type hint be changed from str to str | float?

def format_from_version(version: str) -> "Format":
for fmt in format_implementations():
# Support floating-point versions like `0.2`
if isinstance(version, float):
version = str(version)

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Sep 28, 2023

And here, the type hint for well is str. Why use str(well)? Defensive programming?

def generate_well_dict(
self, well: str, rows: List[str], columns: List[str]
) -> dict:
return {"path": str(well)}

@DimitriPapadopoulos
Copy link
Contributor Author

Isn't parent_dir a str? It could be perhaps None (if input_path is empty or doesn't contain a slash) , but do you really want to use "None" in that corner case?

parent_dir, image_name = os.path.split(input_path)
parent_dir = str(parent_dir)

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

No branches or pull requests

1 participant