Skip to content

Conversation

@mwiebe
Copy link
Contributor

@mwiebe mwiebe commented Jun 14, 2025

What was the problem/requirement? (What/Why)

The library implements a custom OSName for checking which OS it's running on and
reporting in error messages. It also contains '#pragma is-windows' and similar comments
that a code reader will misinterpret.

What was the solution? (How)

  • Instead of the custom OSName, use Python idioms. This will be easier to understand for Python developers and tooling that is processing the code.
    1. For Windows: os.name == "nt"
    2. For POSIX: os.name != "nt"
    3. For MacOS: sys.platform == "darwin"
    4. For a human-readable OS description: platform.platform()
  • Comments '# pragma: is-windows' were unclear, it required investigation to learn that this is a coverage directive. Rename the directive to '# pragma: skip-coverage-windows'

What is the impact of this change?

The code is easier to work with and maintain because it follows Python idioms more closely.

How was this change tested?

Ran the unit test.

As a follow-up test, I ran the deadline-cloud-for-blender integration tests with this library (by running pytest directly in an environment including both instead of relying on hatch). See the related aws-deadline/deadline-cloud-for-blender#241 that I produced in the course of that.

Was this change documented?

No

Is this a breaking change?

No. The OSName class is still in the code, it is commented as deprecated, and the implementation no longer uses it.

Does this change impact security?

No


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mwiebe mwiebe requested a review from a team as a code owner June 14, 2025 00:19
@mwiebe mwiebe force-pushed the remove-custom-osname branch 6 times, most recently from 4fd4ffc to 667c001 Compare June 14, 2025 00:45
@mwiebe mwiebe force-pushed the remove-custom-osname branch 3 times, most recently from f4c4767 to 8afeab6 Compare June 14, 2025 01:00
crowecawcaw
crowecawcaw previously approved these changes Jun 16, 2025
crowecawcaw
crowecawcaw previously approved these changes Jun 16, 2025
* Instead of the custom OSName, use Python idioms. This will be easier
  to understand for Python developers and tooling that is processing the
  code.
     1. For Windows: os.name == "nt"
     2. For POSIX: os.name != "nt"
     3. For MacOS: sys.platform == "darwin"
     4. For a human-readable OS description: platform.platform()
* Comments '# pragma: is-windows' were unclear, it required
  investigation to learn that this is a coverage directive. Rename the
  directive to '# pragma: skip-coverage-windows'

Signed-off-by: Mark <[email protected]>
@sonarqubecloud
Copy link

self._source_path_format: str = source_path_format

destination_os = destination_os.upper()
if destination_os not in ("WINDOWS", "POSIX"):
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to temporarily accept "Linux"/"Macos" as well (whatever the previous values were)? otherwise, previous rules may now raise ValueErrors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both of those should map to POSIX, you're right that it was doing something different before. I'll do a quick survey of the deadline-cloud-for-* projects to get a sense of usage, likely we accept them as input and transform them into "POSIX".

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.

3 participants