Closed ghost closed 8 months ago
The modified time depends on the installation process, so that if I do a fresh install of sopel-mastodon
today, I will get an mtime (and other stat
times) for 1 Nov, but if someone installed it yesterday or installs it tomorrow, they can get 31 Oct or 2 Nov, even if we have exactly the same plugin content. I'm not even sure if this behavior is consistent across platforms, but one counterexample should suffice for my point.
-1 from me, I don't think the potential benefits outweigh the wrinkles, especially when there's an affordance for plugin authors to declare their version.
Oh boy are there a lot of wrinkles.
Logically this would live not in the version
plugin, but in the plugins.handlers.PyFilePlugin
class as an override of the get_version()
method. That part isn't too bad, until you realize that a PyFilePlugin
might also be a directory with an __init__.py
. Then you really get into the question of "yeah, modification time, but whose modification time?"
There's also another problem: A plugin handler doesn't have access to the bot or any of its user data, so formatting the timestamp (assuming you can pick the right one, out of a folder) according to user/channel/config settings is a no-go.
I'm also leaning toward "Just spend one line from your weekly line budget and write __version__ = 'idk whatever'
someplace in your plugin file." As long as the value is (or can be converted to) a string, you're golden.
_For dirty-hack points, you can do __version__ = os.path.getmtime(__file__)
. For supreme overkill dirty-hack points you can getmtime()
, pass it (converted to datetime
) through tools.time.format_time()
, and assign the result as __version__
._
I figured, but no one answered in chat, so GitHub Issue it was! :P
I'm also leaning toward "Just spend one line from your weekly line budget and write
__version__ = 'idk whatever'
someplace in your plugin file." As long as the value is (or can be converted to) a string, you're golden.
You want me to form a new habit?! What a monster! 😜
Requested Feature
If a
myplugin.py
in/plugins
doesn't have__version__ = 'whatever'
present, perhaps we could fallback to displaying the modification date of the file?e.g.:
And the timestamp could follow whatever preference order of user's timezone/formatting desired. (prefer default, then user, then channel? something like that)
Problems Solved
Better than:
in my opinion.
Alternatives
N/A
Notes
For simplicity, I could understand just always using UTC and following ISO 8601.