grscheller.untyped
Useful modules I found difficult to implement in a strictly typed manner.
Modules
module grscheller.untyped.nothing
class Nothing()
Class representing a non-existent value.
- Nothing() is a singleton
- Nothing() instances should be compared with the
isoperator, not== - my[py] becomes problematic when module is strictly typed
- implementing the module becomes vastly more complicated
- in client code my[py] keeps warning you about what you are doing
- maybe using
Anyin this use case is not a bad thing
instance variable: nothing
- nothing = Nothing() is a singleton
1# Copyright 2023-2024 Geoffrey R. Scheller 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15""" 16Useful modules I found difficult to implement in a strictly typed manner. 17 18## Modules 19 20### module `grscheller.untyped.nothing` 21 22#### class `Nothing()` 23 24Class representing a non-existent value. 25 26* Nothing() is a singleton 27* Nothing() instances should be compared with the `is` operator, not `==` 28* my[py] becomes problematic when module is strictly typed 29 * implementing the module becomes vastly more complicated 30 * in client code my[py] keeps warning you about what you are doing 31 * maybe using `Any` in this use case is not a bad thing 32 33#### instance variable: `nothing` 34 35* nothing = Nothing() is a singleton 36 37--- 38 39""" 40__version__ = "0.1.0" 41__author__ = "Geoffrey R. Scheller" 42__copyright__ = "Copyright (c) 2024 Geoffrey R. Scheller" 43__license__ = "Apache License 2.0"