Repository navigation
Conversation
Using `__file__` and manual path logic is deprecated as of Python 3 and this patch updates our settings implementation to follow the new best practices.
| settings = 'settings_%s' % settings | ||
| if not settings.endswith('.py'): | ||
| settings = '.settings_%s' % settings | ||
| elif not settings.endswith('.py'): |
There was a problem hiding this comment.
If a shortname starts with settings_ underscore here then we'll incorrectly end up adding .py to the end. This will fail when we call import_module later.
There was a problem hiding this comment.
I think this was already the case. I'll try to see if I can make this part of the code clearer and stricter.
There was a problem hiding this comment.
It was the case before, but we always expected the file to have .py in the previous implementation. Now we only want to end with .py when we're actually opening a file, as opposed to a module path.
|
|
||
| settings = os.path.join(path, settings) | ||
| settings = imp.load_source('snuba.settings', settings) | ||
| if settings.startswith('/'): |
There was a problem hiding this comment.
Rather than having two if statements, it'd probably be easier to read if you just consolidated. Especially since the .py extension can only be used when the path starts with / now.
There was a problem hiding this comment.
Makes sense, will see what I can do in accordance with my previous comment.
|
I still feel like this code is too permissive and a bit unpredictable with its inputs but I'm keeping it backward-compatible for now. |
| settings_module = importlib.util.module_from_spec(settings_spec) | ||
| settings_spec.loader.exec_module(settings_module) | ||
| else: | ||
| module_format = '.%s' if settings.startswith('settings_') else '.settings_' |
| settings = 'settings_%s' % settings | ||
| if not settings.endswith('.py'): | ||
| settings = '.settings_%s' % settings | ||
| elif not settings.endswith('.py'): |
There was a problem hiding this comment.
It was the case before, but we always expected the file to have .py in the previous implementation. Now we only want to end with .py when we're actually opening a file, as opposed to a module path.
|
|
||
| settings = os.path.join(path, settings) | ||
| settings = imp.load_source('snuba.settings', settings) | ||
| if settings.starstwith('/'): |
There was a problem hiding this comment.
startswith (test build is throwing up errors, just saw this)
## Bump sentry-conventions to 0.11.0 Updates `sentry-conventions` from 0.10.0 to [0.11.0](https://github.com/getsentry/sentry-conventions/releases/tag/0.11.0). ### Changes in 0.11.0 **New Features** - Add `session.id` attribute (#412) - Update several attributes to latest OTel representation (#418) - Add `db.operation.batch.size` (#407) - Add `app.vitals.start.prewarmed` attribute (#379) - Add and deprecate runtime context attributes (#383) - Add Android Runtime (ART) GC and memory attributes (#382) - Add `db.stored_procedure.name` and ensure span name attribute consistency (#398) - Add Cloudflare SDK attributes (#392) - Add missing GCP and FaaS attributes (#403) **Bug Fixes** - Set `pii: 'maybe'` on `faas` string attributes (#415) - Add missing Cloudflare visibility attributes (#408) **Internal** - Remove `sdks` field from attribute schema and definitions (#410)
Using
__file__and manual path logic is deprecated as of Python 3 and this patch updates our settings implementation to follow the new best practices.