cole-brokamp / fr

Implement Frictionless Standards in R
https://cole-brokamp.github.io/fr/
Other
1 stars 1 forks source link

Update for S7 v0.2.0; Set `package = NULL` in `new_class()` #15

Closed t-kalinowski closed 1 week ago

t-kalinowski commented 1 week ago

Starting with S7 0.2.0, S7::new_class() automatically infers the package name, which changes the S3 class of S7 objects defined in a package and causes tests like expect_s3_class(fr_field(), "fr_field") to fail. By default, the S3 class name now includes the package name.

This patch preserves the current S3 class name for S7 classes defined by the package. Alternatively, you could update the tests to use the new S3 class, e.g.,

expect_s3_class(fr_field(), "fr::fr_field")

or,

expect_s3_class(fr_field(), nameOfClass(fr_field))
t-kalinowski commented 1 week ago

Side note: I also updated is_fr_field() to use S7_inherits() instead of base::inherits(), to help future-proof against any further changes to the S3 class of S7 objects.

If you’re targeting only R versions >= 4.3.0, you can also pass the fr_field object directly to base::inherits() like this:

inherits(x, fr_field)
cole-brokamp commented 1 week ago

great news! i've had a lot of trouble in the past with incorporating the package name into the class. i'll take a look very soon!

cole-brokamp commented 1 week ago

thank you! sending this updated version to CRAN now.