-
Notifications
You must be signed in to change notification settings - Fork 64
Clean up code & improve test coverage #249
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
Conversation
|
@ondras12345 I realy like the work you have done; especially the string formating! I was thinking about this myself but stopped as I was not sure how much of it is needed for Python 2.x compatibility. However, as this is droped, these changes make the code more readable! |
I didn't even notice the README said the library still supports Python2, and since setup.py said Also as a side note, if support for 3.8 is declared in OMPython/.github/workflows/Test.yml Line 15 in bfb1153
To be fair, I didn't test my changes with Python 3.8. I should go do that tomorrow... |
I have to save, I did my testing only with Python 3.10+; thus, it would be helpfull to get a feedback that version is the lowest to support before running any tests nobody cares about ... |
|
I tried to run a set of tests with python 3.8, and it doesn't even install. And it's totally my fault, because it fails to parse pyproject.toml, which was introduced by me in #246. Error log: |
|
It seems like it expects a deprecated format:
The new format is only supported since setuptools 77.0.0, which in turn require python 3.9: https://github.com/pypa/setuptools/blob/v77.0.0/pyproject.toml#L25. If we really want python 3.8 compatibility, we might have to drop the license specifier in pyproject.toml. |
|
I think we should update to Python version Let me know once you have finalized the PR and I will try to review and merge it asap. |
|
I'm currently working on resolving the conflicts. I don't think jumping all the way to 3.12 is necessary. E.g. debian 12 ships with python 3.11.2, so there is value in supporting older python version for linux users.
CI tests currently run on 3.10 and 3.12: OMPython/.github/workflows/Test.yml Line 15 in 630229a
and they are passing. It should be safe to say python >= 3.10 is supported. It's not like we need the new features introduced in 3.11 and 3.12. |
- use f-strings to make sendExpression() arguments easier to read, - use pathlib.Path to convert \ to / in file paths on Windows - fix a few bugs (mostly missing spaces in error strings)
It behaves differently before and after simulate()
I'm pretty sure this also fixes a bug: the only Exception I can see os.path.join() raise in _get_omc_path() is when self.omhome is None, which shouldn't really happen (the constructor checks it). I think the intention was to check whether the file actually exists, so I do that instead.
... instead of raw sendExpression. Seems cleaner and improves test coverage.
... by dropping Python2 support
... except for logging calls. It probably doesn't matter, but the built-in %-formatting does not run when logging is disabled, improving performance.
... probably due to missing .exe suffix.
The csv module documentation says to open the file with newline='': https://docs.python.org/3/library/csv.html#id4 Also, I'm pretty sure this isn't how you are supposed to use csv.writer. delimiter='\n' doesn't seem right. We should either let the csv writer actually generate the rows, or remove it altogether and just write the string rows into the file.
20c24dc to
2be6fbd
Compare
I support staying with Python >= 3.10 as this version is working well in the tests; why should we limit the possible user range without a really need for such a change? |
|
I have rebased my branch onto master and fixed the conflicts (there was a lot of them). |
As discussed in OpenModelica#249
Sorry for the work ... I will try to keep the next changes generic such that these can be easily rebased based on your PR |
arun3688
left a comment
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.
looks good
adeas31
left a comment
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.
LGTM. Thanks!
As discussed in #249 Co-authored-by: Adeel Asghar <[email protected]>
This PR tries to clean up the code by:
.format(),.as_posix()instead ofos.path.*and manually replacing\with/,There should be no significant changes in behavior (except for the last commit "Fix createCSVData on Windows", which removes an extra newline at the end of the csv file).
It also adds tests, improving
OMPython/__init__.pycoverage to 73% on Linux.