question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecation warning on Python 3.5

See original GitHub issue

Getting a deprecation warning on Python 3.5 wen importing Table and Col. It’s related to an import that doesn’t appear to be used.

Hopefully this is an easy fix.

$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
$ uname -a
Linux nylon 4.4.0-45-generic #66-Ubuntu SMP Wed Oct 19 14:12:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from flask_table import Table, Col
/usr/local/lib/python3.5/dist-packages/flask_table/columns.py:5: ExtDeprecationWarning: Importing flask.ext.babel is deprecated, use flask_babel instead.
 from flask.ext.babel import gettext as _
>>> 

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
plumdogcommented, Feb 4, 2017

@palisadoes @smewp You definitely can do this with subclassing Col and overriding the td method and passing something like attrs={'class': 'myclass'} to element.

This is probably fine if you just have one column that you want to add a class to, but is potentially a pain if you want to be able to apply this to a range of columns all over your application, in which case you may have to subclass every column class.

The best approach also really depends on whether the class that you’re setting on the tds for a column depends on the item, or if they’re all the same. Eg, do you want to write code that looks like:

class MyTable(Table):
    mycol = Col(td_attrs={'class': 'warning'})  # this doesn't work at present

which is pretty generic, and I would consider adding support for this.

Or code that looks like:

class TDClassCoMixin(object):

    def td(self, item, attr):
        content = self.td_contents(item, self.get_attr_list(attr))
        td_class = ... # something application specific to get the td class from the item, and/or based on the attr
        attrs = {}
        if td_class:
            attrs['class'] = td_class
        return element('td', content=content, escape_content=False, attrs=attrs)

class MyAppCol(TDClassColMixin, flask_table.Col):
    pass

class MyAppBoolCol(TDClassColMixin, flask_table.BoolCol):
    pass

# and so on for each column class you're using, then import and use these classes rather than the originals from flask_table

And that’s all application specific, so I don’t think it’ll fit so easily into flask table.

Just as an extra thought - and it depends what you’re doing - you might want to do this with CSS using nth-child, rather than adding classes to the tds at all.

So TLDR, it really depends on your use case - whether you have one or two specific columns you want to add classes to or loads of them, and whether the classes are the same for every td in a column. I hope the above options help, or you may want to post more info about what you’re trying to create. (If so, consider opening a new issue for this.)

0reactions
plumdogcommented, Feb 7, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

warnings — Warning control — Python 3.11.1 documentation
Base category for warnings about deprecated features when those warnings are intended for other Python developers (ignored by default, unless triggered by ...
Read more >
DeprecationWarning: formatargspec is deprecated since ...
I often run our tests with -Wa to catch deprecation warnings and having this still be open in newrelic is causing extra noise....
Read more >
Deprecation Warning while installing wheel for scikit-learn
It's warning you that you're using an unsupported version of Python (2.7) and should probably upgrade, otherwise you might run into problems.
Read more >
Who should see Python deprecation warnings? - LWN.net
The first line filters out DeprecationWarning events, such as the warnings regarding await and async in the 3.6 release. Those warnings were also...
Read more >
Using Python Console with "-Wa" raises "DeprecationWarning
Configure Python Console to use Interpreter Flag -Wa (I supplied my whole config, ... DeprecationWarning: `formatargspec` is deprecated since Python 3.5.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found