optimism 3.1.1__tar.gz → 3.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {optimism-3.1.1 → optimism-3.1.2}/PKG-INFO +3 -3
  2. optimism-3.1.2/optimism/__init__.py +21 -0
  3. {optimism-3.1.1 → optimism-3.1.2}/optimism/optimism.py +57 -31
  4. {optimism-3.1.1 → optimism-3.1.2}/optimism.egg-info/PKG-INFO +3 -3
  5. {optimism-3.1.1 → optimism-3.1.2}/pyproject.toml +1 -1
  6. {optimism-3.1.1 → optimism-3.1.2}/setup.cfg +2 -2
  7. optimism-3.1.1/optimism/__init__.py +0 -12
  8. {optimism-3.1.1 → optimism-3.1.2}/LICENSE.txt +0 -0
  9. {optimism-3.1.1 → optimism-3.1.2}/README.md +0 -0
  10. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/a.txt +0 -0
  11. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/b.txt +0 -0
  12. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/bad.py +0 -0
  13. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/basic.py +0 -0
  14. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/bits.py +0 -0
  15. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/block.py +0 -0
  16. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/catch_and_release.py +0 -0
  17. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/code.py +0 -0
  18. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/core.py +0 -0
  19. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/doc_example.py +0 -0
  20. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/doctests.py +0 -0
  21. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/errors.py +0 -0
  22. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/files.py +0 -0
  23. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/fragments.py +0 -0
  24. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/io_example.py +0 -0
  25. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/literals.py +0 -0
  26. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/memoryReports.py +0 -0
  27. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/multi.py +0 -0
  28. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/reverse_tracing.py +0 -0
  29. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/runfile.py +0 -0
  30. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/skip.py +0 -0
  31. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/structure.py +0 -0
  32. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/suites.py +0 -0
  33. {optimism-3.1.1 → optimism-3.1.2}/optimism/examples/tracing.py +0 -0
  34. {optimism-3.1.1 → optimism-3.1.2}/optimism/py.typed +0 -0
  35. {optimism-3.1.1 → optimism-3.1.2}/optimism/test_examples.py +0 -0
  36. {optimism-3.1.1 → optimism-3.1.2}/optimism.egg-info/SOURCES.txt +0 -0
  37. {optimism-3.1.1 → optimism-3.1.2}/optimism.egg-info/dependency_links.txt +0 -0
  38. {optimism-3.1.1 → optimism-3.1.2}/optimism.egg-info/requires.txt +0 -0
  39. {optimism-3.1.1 → optimism-3.1.2}/optimism.egg-info/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: optimism
3
- Version: 3.1.1
4
- Summary: Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.11+.
3
+ Version: 3.1.2
4
+ Summary: Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.8+.
5
5
  Home-page: https://cs.wellesley.edu/~pmwh/optimism/docs/optimism.html
6
6
  Author: Peter Mawhorter
7
7
  Author-email: pmawhort@wellesley.edu
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: BSD License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Natural Language :: English
16
16
  Classifier: Topic :: Education
17
- Requires-Python: >=3.11
17
+ Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE.txt
20
20
  Provides-Extra: test
@@ -0,0 +1,21 @@
1
+ """
2
+ This package init just imports everything from optimism.py, including
3
+ explicitly the version number (which otherwise would be skipped since it
4
+ starts with '_'). That way, importing optimism-the-package is the same as
5
+ importing optimism-the-file, except that private variables are not
6
+ exported by the package. So you can distribute the package OR just the
7
+ optimism.py file and both should work the same.
8
+ """
9
+
10
+ from .optimism import *
11
+
12
+ # Setuptools versions on Python 3.10 won't allow us to just import the
13
+ # version from optimism, but we want the version to be defined in that
14
+ # file so that a single-file distribution is equivalent to this packaged
15
+ # distribution. So we define a version here as well, but...
16
+ __version__ = "3.1.2"
17
+
18
+ # ...then we assert it matches so testing will catch it if I forget to
19
+ # keep them in sync before a release. T_T
20
+ from .optimism import __version__ as match
21
+ assert __version__ == match
@@ -200,6 +200,8 @@ TODO: Workaround for tracing in interactive console?
200
200
 
201
201
  ## Changelog
202
202
 
203
+ - Version 3.1.2 Adds shims to support Python versions 3.8-3.10 again,
204
+ rather than just 3.11+.
203
205
  - Version 3.1.1 reformulates the module as a package so that it can add
204
206
  a `py.typed` file so that the new type hints are recognized by `mypy`.
205
207
  The package version no longer exports private names from the
@@ -344,14 +346,14 @@ TODO: Workaround for tracing in interactive console?
344
346
 
345
347
  # TODO: Cache compiled ASTs!
346
348
 
347
- __version__ = "3.1.1"
349
+ __version__ = "3.1.2"
348
350
 
349
351
  from typing import (
350
- Any, Dict, List, Optional, Tuple, TypeAlias, Literal as LiteralType,
351
- Callable, TypedDict, cast, Iterable, Iterator, Protocol, TextIO,
352
- Union, Sequence, Type, TypeVar, Generic, Collection, Set, get_args
352
+ Any, Dict, List, Optional, Tuple, Literal as LiteralType, Callable,
353
+ TypedDict, cast, Iterable, Iterator, Protocol, TextIO, Union,
354
+ Sequence, TypeVar, Generic, Collection, Set, get_args
353
355
  )
354
- from types import NoneType, FunctionType, ModuleType, FrameType
356
+ from types import FunctionType, ModuleType, FrameType
355
357
 
356
358
  import sys, traceback, inspect, linecache, ast, copy, io, os, re, types,\
357
359
  builtins, cmath, textwrap, warnings, functools, token, tokenize
@@ -359,18 +361,27 @@ import sys, traceback, inspect, linecache, ast, copy, io, os, re, types,\
359
361
  import doctest
360
362
  from typing import Callable, Any
361
363
 
364
+ #------------------#
365
+ # Version Handling #
366
+ #------------------#
362
367
 
363
368
  # Flags for feature-detection on the ast module
364
369
  HAS_WALRUS = hasattr(ast, "NamedExpr")
365
370
  SPLIT_CONSTANTS = hasattr(ast, "Num")
366
371
 
372
+ # Type is required before 3.9 but deprecated in that version
373
+ if sys.version_info >= (3, 9):
374
+ Type = type
375
+ else:
376
+ from typing import Type
377
+
367
378
 
368
- #
379
+ # Versions of Python before 3.11 don't support Unpack
369
380
  try:
370
381
  from typing import Unpack
371
382
  except ImportError:
372
383
  # We need to ignore "already defined by import" error here
373
- class Unpack: # type: ignore
384
+ class UnpackShim: # type: ignore
374
385
  """
375
386
  A fake stub for `typing.Unpack` on Python versions where that's
376
387
  not available; allows get-item just like `Unpack` but returns
@@ -379,6 +390,19 @@ except ImportError:
379
390
  def __getitem__(self, _):
380
391
  return Any
381
392
 
393
+ Unpack = UnpackShim()
394
+
395
+ # Versions of Python before 3.10 don't support TypeAlias
396
+ try:
397
+ from typing import TypeAlias
398
+ except ImportError:
399
+ TypeAlias = Type
400
+
401
+ # Versions of Python before 3.10 don't support NoneType
402
+ try:
403
+ from types import NoneType
404
+ except ImportError:
405
+ NoneType = type(None)
382
406
 
383
407
  #----------------#
384
408
  # Monkey Patches #
@@ -698,7 +722,10 @@ Type variable for `ClassInfo` definition.
698
722
  """
699
723
 
700
724
 
701
- ClassInfo: TypeAlias = Union[type[T], Tuple['ClassInfo', ...], type[Union]]
725
+ if sys.version_info > (3, 10):
726
+ ClassInfo: TypeAlias = Union[Type[T], Tuple['ClassInfo', ...], Type[Union]]
727
+ else:
728
+ ClassInfo: TypeAlias = Union[Type[T], Tuple['ClassInfo', ...]]
702
729
  """
703
730
  The kinds of things that can be passed as the second argument of
704
731
  `instanceof`: types, tuples of types (perhaps nested) and `Union`s.
@@ -4839,7 +4866,7 @@ class NumArgs(TypedDict, total=False):
4839
4866
  types which inherit from `ASTRequirement` can use it as the type of
4840
4867
  their **kwargs. All slots are optional.
4841
4868
  """
4842
- min: Union[type[DefaultMin], None, int]
4869
+ min: Union[Type[DefaultMin], None, int]
4843
4870
  max: Optional[int]
4844
4871
  n: Optional[int]
4845
4872
 
@@ -4874,7 +4901,7 @@ class ASTRequirement:
4874
4901
  def __init__(
4875
4902
  self,
4876
4903
  *,
4877
- min: Union[type[DefaultMin], None, int] = DefaultMin,
4904
+ min: Union[Type[DefaultMin], None, int] = DefaultMin,
4878
4905
  max: Optional[int] = None,
4879
4906
  n: Optional[int] = None
4880
4907
  ):
@@ -6294,7 +6321,7 @@ class Constant(ASTRequirement):
6294
6321
  def __init__(
6295
6322
  self,
6296
6323
  value: Any = AnyValue,
6297
- types: Union[type, Tuple[type, ...], type[AnyType]] = AnyType,
6324
+ types: Union[type, Tuple[type, ...], Type[AnyType]] = AnyType,
6298
6325
  **kwargs: Unpack[NumArgs]
6299
6326
  ) -> None:
6300
6327
  """
@@ -6427,7 +6454,7 @@ A union of the types which can be declared as literals.
6427
6454
 
6428
6455
  def getLiteralValue(astNode: ast.AST) -> Union[
6429
6456
  LiterallyDeclarable,
6430
- type[AnyValue]
6457
+ Type[AnyValue]
6431
6458
  ]:
6432
6459
  """
6433
6460
  For an AST node that's entirely made up of `Constant` and/or
@@ -6521,7 +6548,7 @@ class Literal(ASTRequirement):
6521
6548
  def __init__(
6522
6549
  self,
6523
6550
  value: Any = AnyValue,
6524
- types: Union[type, Tuple[type, ...], type[AnyType]] = AnyType,
6551
+ types: Union[type, Tuple[type, ...], Type[AnyType]] = AnyType,
6525
6552
  **kwargs: Unpack[NumArgs]
6526
6553
  ) -> None:
6527
6554
  """
@@ -6669,7 +6696,7 @@ class Literal(ASTRequirement):
6669
6696
 
6670
6697
  # Coerce type of our own value to type of the value provided
6671
6698
  valType = cast(
6672
- Union[type[set], type[list], type[tuple], type[dict]],
6699
+ Union[Type[set], Type[list], Type[tuple], Type[dict]],
6673
6700
  valType
6674
6701
  )
6675
6702
  checkAgainst = valType(self.value)
@@ -6744,8 +6771,8 @@ A type variable for types that are ast.AST subtypes.
6744
6771
  """
6745
6772
 
6746
6773
  OpMapEntry: TypeAlias = Tuple[
6747
- Tuple[type[ast.AST], ...],
6748
- Tuple[type[ast.AST], ...]
6774
+ Tuple[Type[ast.AST], ...],
6775
+ Tuple[Type[ast.AST], ...]
6749
6776
  ]
6750
6777
  """
6751
6778
  The generic type for entries in our `OP_MAP` operator mapping
@@ -6871,14 +6898,14 @@ class SpecificNode(ASTRequirement, Generic[AT]):
6871
6898
  string, so other `ASTRequirement` sub-classes are preferable if one
6872
6899
  of them can match what you want.
6873
6900
  """
6874
- nodeTypes: Tuple[type[AT], ...]
6901
+ nodeTypes: Tuple[Type[AT], ...]
6875
6902
  """
6876
6903
  The tuple of allowed `ast.AST` node types
6877
6904
  """
6878
6905
 
6879
6906
  def __init__(
6880
6907
  self,
6881
- nodeTypes: Union[type[AT], Sequence[type[AT]]],
6908
+ nodeTypes: Union[Type[AT], Sequence[Type[AT]]],
6882
6909
  filterFunction: Optional[Callable[[ast.AST], bool]] = None,
6883
6910
  **kwargs: Unpack[NumArgs]
6884
6911
  ) -> None:
@@ -7112,22 +7139,21 @@ which has slots that used to contain complex sub-objects replaced with
7112
7139
  `MemReference` objects. See `memoryMap`.
7113
7140
  """
7114
7141
 
7115
-
7116
- SmallType: TypeAlias = Union[
7117
- int,
7118
- float,
7119
- complex,
7120
- bool,
7121
- NoneType # type: ignore
7122
- ]
7142
+ SmallTypes: Tuple[Type] = (int, float, complex, bool, NoneType)
7123
7143
  """
7124
7144
  The object types which are small enough to fit into a single field
7125
7145
  without using a pointer in theory, which we thus represent without using
7126
- a `MemReference` in a memory report.
7146
+ a `MemReference` in a memory report. This is a tuple so it can be used
7147
+ with `isinstance`.
7148
+ """
7149
+ # Note that NoneType is used over None here because we use isinstance
7150
+ # later so it cannot just be None. If we only wanted to support Python
7151
+ # 3.10+, we could use the union directly in isinstance.
7152
+
7153
+ SmallType: TypeAlias = Union[int, float, complex, bool, NoneType]
7154
+ """
7155
+ A union of the `SmallTypes`.
7127
7156
  """
7128
- # Note that NoneType is used over None here because we use get_args and
7129
- # isinstance later so it cannot just be None. If we only wanted to
7130
- # support Python 3.10+, we could use the union directly in isinstance.
7131
7157
 
7132
7158
 
7133
7159
  def memoryMap(
@@ -7194,7 +7220,7 @@ def memoryMap(
7194
7220
 
7195
7221
  shallow: Union[tuple, list, set, dict]
7196
7222
  if (
7197
- isinstance(obj, get_args(SmallType))
7223
+ isinstance(obj, SmallTypes)
7198
7224
  or (INLINE_STRINGS_IN_MEMORY_REPORTS and isinstance(obj, str))
7199
7225
  ):
7200
7226
  # Simple values are used as-is:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: optimism
3
- Version: 3.1.1
4
- Summary: Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.11+.
3
+ Version: 3.1.2
4
+ Summary: Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.8+.
5
5
  Home-page: https://cs.wellesley.edu/~pmwh/optimism/docs/optimism.html
6
6
  Author: Peter Mawhorter
7
7
  Author-email: pmawhort@wellesley.edu
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: BSD License
14
14
  Classifier: Operating System :: OS Independent
15
15
  Classifier: Natural Language :: English
16
16
  Classifier: Topic :: Education
17
- Requires-Python: >=3.11
17
+ Requires-Python: >=3.8
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE.txt
20
20
  Provides-Extra: test
@@ -1,3 +1,3 @@
1
1
  [build-system]
2
- requires = [ "setuptools >= 69.0", "wheel" ]
2
+ requires = [ "setuptools", "wheel" ]
3
3
  build-backend = "setuptools.build_meta"
@@ -1,7 +1,7 @@
1
1
  [metadata]
2
2
  name = optimism
3
3
  version = attr: optimism.__version__
4
- description = Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.11+.
4
+ description = Very simple testing framework suitable for beginner programmers, with easy functions for accomplishing most common testing tasks like providing input. Requires Python 3.8+.
5
5
  long_description = file: README.md
6
6
  long_description_content_type = text/markdown
7
7
  url = https://cs.wellesley.edu/~pmwh/optimism/docs/optimism.html
@@ -19,7 +19,7 @@ classifiers =
19
19
  Topic :: Education
20
20
 
21
21
  [options]
22
- python_requires = >=3.11
22
+ python_requires = >=3.8
23
23
  provides = optimism
24
24
  packages = optimism
25
25
 
@@ -1,12 +0,0 @@
1
- """
2
- This package init just imports everything from optimism.py, including
3
- explicitly the version number (which otherwise would be skipped since it
4
- starts with '_'). That way, importing optimism-the-package is the same as
5
- importing optimism-the-file, except that private variables are not
6
- exported by the package. So you can distribute the package OR just the
7
- optimism.py file and both should work the same.
8
- """
9
-
10
- from .optimism import *
11
-
12
- from .optimism import __version__
File without changes
File without changes
File without changes