-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
surplus 2.0.0 #19
Merged
Merged
surplus 2.0.0 #19
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataclasses cannot be frozen and have slots, a bug that probably will never be fixed
i dont like it, but that's how it'll have to be python/typing#1333 s+: also, add __str__ support for query types (#18)
pyproj: remove py.typed include, poetry does this automatically ci(qc): fix typo ci(release): duplicate non-versioned wheels
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this release has rewritten surplus to be much more flexible for potential future changes:
this release also breaks the previous exposed api functions
what is new
Behaviour
objectResult
object for safer value retrieval instead of the previous(bool, value)
tuplewhat has been removed
surplus.handle_query()
instead, use
.to_lat_long_coord()
on your surplus 2.x query objectwhat has remained
surplus.surplus()
, the functionsurplus.parse_query()
, the functionwhat has changed
surplus.surplus()
reverser
anddebug
arguments are now under the unifiedsurplus.Behaviour
objectsurplus.Result[str]
for safer error handlingsurplus.parse_query()
query
anddebug
arguments are now under the unifiedsurplus.Behaviour
objectsurplus.Result[surplus.Query]
for safer error handlingsurplus.Latlong
attributes
lat
andlong
have been renamed to.latitude
and.longitude
respectivelysurplus.Localcode
renamed to
surplus.LocalCodeQuery
Localcode.full_length()
renamed to
LocalCodeQuery.to_full_plus_code()
, and returns asurplus.Result[str]
for safer error handlingother notable changes
python 3.11 is the new minimum
surplus.Result
is a NamedTuple with generics, and generic NamedTuples came about in python 3.11 (python/cpython#88089).i did try to keep 3.10 support by using a dataclass which fails when it is frozen with slots, a bug which was dismissed in the python bug tracker (python/cpython#90055)
i honestly have already forgotten why we needed slots other than probably a case of premature optimisation. hilariously,
frozen=True
already gets a dataclass as close as practically one should to a NamedTuple. oh well.if you're reading this (hi! thanks for using surplus!) and need 3.10 support because you can't use 3.11, there's your solution then. change
surplus.Result
from a generic NamedTuple to a generic frozen dataclass.anyways, if somebody really, really, needs surplus with python 3.10 support, i might downgrade the generic namedtuple to a generic frozen dataclass for a special branch. or python 3.10 goes end of life. whichever comes first. i doubt anybody other than i uses surplus anyways. plus codes to iOS-Shortcuts-like shareable text is pretty niche after all.
as for why it was 3.10 in the past and not something more sane like 3.8, pluscodes, a dependency of surplus, requires
>=3.10
.mypy support via py.typed, at the cost not being a single-file package
due to a bug where single-file packages can't include a py.typed marker (python/typing#1333), the surplus script is now located in directory
before
i quite liked this as i have been following this format for past single-file projects, as having everything accessible makes more sense in my opinion
after
while this means embedding surplus is slightly different (but still doable!) - mypy wont throw errors at you.
side note - i did not know a py.typed was needed for proper mypy support. woops!