Skip to content

Commit

Permalink
Merge pull request #499 from ExaWorks/remove_typing_compat
Browse files Browse the repository at this point in the history
Removed dependency on typing_compat and bumped the minimum python
  • Loading branch information
hategan authored Jan 16, 2025
2 parents e05d3d0 + 0cdcf01 commit acc02c4
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ updates:
- dependency-name: "psutil"
- dependency-name: "pystache"
- dependency-name: "typeguard"
- dependency-name: "typing-compat"
- dependency-name: "packaging"

2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, 3.10]
python-version: [3.8, 3.9, 3.10, 3.11, 3.12]
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 0 additions & 3 deletions .mypy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,3 @@ ignore_missing_imports = True

[mypy-pystache.*]
ignore_missing_imports = True

[mypy-typing_compat.*]
ignore_missing_imports = True
6 changes: 3 additions & 3 deletions QuickStart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ This document will guide you through the install procedure and your first Hello
- [Hello World example](#hello-world)

## Requirements
- python3.7+
- python3.8+

## Install PSI/J

If you have conda installed you might want to start from a fresh environment. This part is not installing PSI/J but setting up a new environment with the specified python version:

1. `conda create -n psij python=3.7`
1. `conda create -n psij python=3.8`
2. `conda activate psij`


Expand All @@ -35,7 +35,7 @@ Install PSI/J from the GitHub repository:
## Hello World

**Requirements**
- python3.7
- python3.8
- Job executor, e.g. Slurm in this example

**Steps**
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ or from source.
Requirements
^^^^^^^^^^^^

The only requirements are Python 3.7+ and pip, which almost always
The only requirements are Python 3.8+ and pip, which almost always
comes with Python.

Install from PIP
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
psutil >=5.9, <=6.1.1
pystache>=0.6.0
typeguard>=3.0.1
typing-compat
packaging >= 24.0, <= 24.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@
},

install_requires=install_requires,
python_requires='>=3.7'
python_requires='>=3.8'
)
15 changes: 7 additions & 8 deletions src/psij/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from io import StringIO, TextIOBase
from pathlib import Path
from typing import Optional, Dict, Union, List, IO, AnyStr, TextIO
import typing_compat

from psij import ResourceSpec
from psij.job_attributes import JobAttributes
Expand Down Expand Up @@ -135,12 +134,12 @@ def _from_psij_object(self, o: Union[JobSpec, JobAttributes, ResourceSpec]) \

def _canonicalize_type(self, t: object) -> object:
# generics don't appear to be subclasses of Type, so we can't really use Type for t
origin = typing_compat.get_origin(t)
origin = typing.get_origin(t)
if origin == Optional:
# Python converts Optional[T] to Union[T, None], so this shouldn't happen
return typing_compat.get_args(t)[0]
return typing.get_args(t)[0]
elif origin == Union:
args = typing_compat.get_args(t)
args = typing.get_args(t)
if args[0] == NoneType:
return args[1]
elif args[1] == NoneType:
Expand Down Expand Up @@ -171,10 +170,10 @@ def _from_object(self, o: object, t: object) -> object:
else:
if t == Union[str, Path] or t == Optional[Union[str, Path]]:
return str(o)
if typing_compat.get_origin(t) == dict:
if typing.get_origin(t) == dict:
assert isinstance(o, dict)
return self._from_dict(o)
if typing_compat.get_origin(t) == list:
if typing.get_origin(t) == list:
assert isinstance(o, list)
return self._from_list(o)
raise ValueError('Cannot convert type "%s".' % t)
Expand Down Expand Up @@ -249,10 +248,10 @@ def _to_object(self, s: object, t: object) -> object:
if t == Union[str, Path] or t == Optional[Union[str, Path]]:
assert isinstance(s, str)
return Path(s)
if typing_compat.get_origin(t) == dict:
if typing.get_origin(t) == dict:
assert isinstance(s, dict)
return self._to_dict(s)
if typing_compat.get_origin(t) == list:
if typing.get_origin(t) == list:
assert isinstance(s, list)
return self._to_list(s)
raise ValueError('Cannot convert type "%s".' % t)
Expand Down
2 changes: 1 addition & 1 deletion web/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2><i class="fab fa-python"></i> Installing <span class="psij-font">PSI/J</span
<div style="margin-top: 1em">
The psij-python library has the following requirements:
<ul>
<li>Python 3.7 or later
<li>Python 3.8 or later
<li>Ubuntu 16.04 or later (or an equivalent Linux distribution)
<li>OS X 10.10 or later
</ul>
Expand Down

0 comments on commit acc02c4

Please sign in to comment.