Skip to content

Deprecate setting of custom attributes on geometry objects#1183

Merged
jorisvandenbossche merged 5 commits intoshapely:masterfrom
jorisvandenbossche:deprecate-custom-attributes
Sep 28, 2021
Merged

Deprecate setting of custom attributes on geometry objects#1183
jorisvandenbossche merged 5 commits intoshapely:masterfrom
jorisvandenbossche:deprecate-custom-attributes

Conversation

@jorisvandenbossche
Copy link
Copy Markdown
Member

See #1181 (and https://github.com/Toblerity/Shapely/pull/1180/files#r693378882). If we want to disallow it for Shapely 2.0, this is adding a deprecation warning for it for 1.8

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 24, 2021

Coverage Status

Coverage increased (+0.05%) to 85.443% when pulling ec19105 on jorisvandenbossche:deprecate-custom-attributes into 8eaac9d on Toblerity:master.

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

@sgillies @mwtoews you're fine with this additional deprecation?

This was referenced Sep 8, 2021
Copy link
Copy Markdown
Member

@mwtoews mwtoews left a comment

Choose a reason for hiding this comment

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

Changes look good for shapely 1.8.

@mwtoews
Copy link
Copy Markdown
Member

mwtoews commented Sep 22, 2021

The only thing we can't warn against is users that extend geometry types:

from shapely.geometry import Point

class MyPoint(Point):
    extra = 123

mp = MyPoint(2, 4)
print(mp.extra)  # 123
mp.extra = 456
print(mp.extra)  # 456

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

I suppose that in theory we could also add a warning when subclassing the geometry classes (with a metaclass, see eg https://stackoverflow.com/questions/16056574/how-does-python-prevent-a-class-from-being-subclassed), but not directly sure how that impacts other things.

@jorisvandenbossche
Copy link
Copy Markdown
Member Author

I am going to interpret the thumbs up of @sgillies at #1181 as an approval of the general idea, and merge this.

@jorisvandenbossche jorisvandenbossche merged commit 9963cca into shapely:master Sep 28, 2021
@jorisvandenbossche jorisvandenbossche deleted the deprecate-custom-attributes branch September 28, 2021 07:28
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