"get_orm_column_names(SomeThing) == {}", get_orm_column_names(SomeThing, sort=True), ) st = SomeThing() st.somefunc() # Now, which columns does the PyCharm type checker/autocomplete find? # Column? Autocomplete? Inspect code OK? # a YES YES YES # b_from_init_classdict no - - # b_from_init_cls YES YES YES # b_from_new_classdict YES NO YES # b_from_new_cls YES YES YES # c YES YES YES # d1 to d5 YES NO YES # nonexistent - - [yes!] log.debug("{}", st.a) log.debug("{}", st.b_from_init_cls) log.debug("{}", st.b_from_new_classdict) log.debug("{}", st.b_from_new_cls) log.debug("{}", st.c) log.debug("{}", st.d3) act_with(st) x = SimpleTask() log.info( "get_orm_column_names(SimpleTask) == {}", get_orm_column_names(SimpleTask, sort=True), ) ct = ComplexTask() log.info(
# searches ~/.fonts for fonts. That's fine unless a user is calling with # sudo -u USER, leaving $HOME as it was but removing the permissions - then # matplotlib crashes out with e.g. # PermissionError: [Errno 13] Permission denied: '/home/rudolf/.fonts/SABOI___.TTF' # noqa # Note that an empty string won't help either, since the check is # "is not None". # You can't assign None to an os.environ member; see # http://stackoverflow.com/questions/3575165; do this: if ENVVAR_HOME in os.environ: _old_home = os.environ[ENVVAR_HOME] del os.environ[ENVVAR_HOME] else: _old_home = None # 5. Import matplotlib log.debug("Importing matplotlib (can be slow) (MPLCONFIGDIR={})...", _mpl_config_dir) # noinspection PyUnresolvedReferences import matplotlib # noqa: E402,F401 # 6. Restore $HOME if _old_home is not None: os.environ[ENVVAR_HOME] = _old_home # 7. Set the backend # REPLACED BY OO METHOD # matplotlib.use("Agg") # also the default backend # ... http://matplotlib.org/faq/usage_faq.html#what-is-a-backend # ... http://matplotlib.org/faq/howto_faq.html # matplotlib.use("cairo") # cairo backend corrupts some SVG figures # Load this once so we can tell the user we're importing it and it's slow # REPLACED BY OO METHOD # import matplotlib.pyplot # noqa
""" failmsg = ( f"pymysql_crash_on_bad_conversion: attempting to convert bad Python " f"object to database: {obj!r}. Mapping dict is {mapping!r}.") log.critical(failmsg) raise RuntimeError(failmsg) # ----------------------------------------------------------------------------- # Pendulum; see https://pypi.org/project/pendulum/ -- but note that it says # "pymysql.converters.conversions" but should say # "pymysql.converters.encoders". # ----------------------------------------------------------------------------- if MySQLdb: log.debug("Hacking MySQLdb to support pendulum.DateTime") if CRASH_ON_BAD_CONVERSIONS: MySQLdb.converters.conversions[ Pendulum] = mysqldb_crash_on_bad_conversion # noqa else: MySQLdb.converters.conversions[ Pendulum] = MySQLdb.converters.DateTime2literal # noqa if pymysql: log.debug("Hacking pymysql to support pendulum.DateTime") if CRASH_ON_BAD_CONVERSIONS: pymysql.converters.encoders[Pendulum] = pymysql_crash_on_bad_conversion else: pymysql.converters.encoders[ Pendulum] = pymysql.converters.escape_datetime # noqa # And also, as per the source code and