19159

ctags, vim and python code

Question:

I generate ctags with the following command

ctags -R --fields=+l --languages=python --python-kinds=-iv -f ./tags apps/employees/models.py

and this is my code

from django.contrib.auth.models import AbstractUser from django.contrib.postgres.fields import HStoreField from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from author.decorators import with_author from django_extensions.db.models import TimeStampedModel from django_fsm import FSMField from imagekit import models as imagekitmodels from imagekit.processors import ResizeToFill from phonenumber_field.modelfields import PhoneNumberField from timezone_field import TimeZoneField from libs import utils # Solution to avoid unique_together for email AbstractUser._meta.get_field('email')._unique = True def upload_user_media_to(instance, filename): """Upload media files to this folder""" return '{}/{}/{}'.format( instance.__class__.__name__.lower(), instance.id, utils.get_random_filename(filename)) __all__ = [ 'Employee'] @with_author class Employee(AbstractUser, TimeStampedModel): """Custom user model. Attributes: department (Department): What department the employee is in avatar (file): user's avatar, cropeed to fill 300x300 px notifications (dict): settings for notifications to user first_name (str): first name last_name (str): last name email (str): email (should be unique), this is our username field is_staff (bool): designates whether the user can log into this admin site is_active (bool): designates whether this user should be treated as active date_joined (datetime): when user joined """ HIRED = 'H' ACTIVE = 'A' SICK = 'S' VACATION = 'V' PTO = 'P' FIRED = 'F' STATUSES = ( (HIRED, 'hired'), (ACTIVE, 'active'), (SICK, 'sick'), (VACATION, 'vacation'), (PTO, 'pto'), (FIRED, 'fired'), ) status = FSMField( default=HIRED, choices=STATUSES, protected=True) branch = models.ForeignKey( 'company.Branch', null=True, related_name='employees', editable=True) department = models.ForeignKey( 'company.Department', help_text='What department the employee is in', null=True, related_name='employees', editable=True) worktype = models.ForeignKey( 'company.Worktype', null=True, related_name='employees', editable=True) recruiter = models.ForeignKey( 'Employee', null=True, related_name='recruits', editable=True) # direct supervisor of the employee supervisor = models.ForeignKey( 'Employee', null=True, related_name='supervisees', editable=True) # other people interested in this employee # activities followers = models.ManyToManyField( 'self', related_name='following') username_ldap = models.CharField( max_length=255, null=True) is_utilized = models.BooleanField( default=True) is_contractor = models.BooleanField( default=False) is_daily_report_required = models.BooleanField( default=True) utilization = models.IntegerField( default=100, validators=[ MinValueValidator(0), MaxValueValidator(100)]) avatar = imagekitmodels.ProcessedImageField( upload_to=upload_user_media_to, processors=[ResizeToFill(300, 300)], format='PNG', options={'quality': 100}, editable=True, null=True, blank=False) date_start = models.DateTimeField( _('date started'), null=True, default=timezone.now) address = models.CharField( max_length=255, blank=True) city = models.CharField( max_length=255, blank=True) state = models.CharField( max_length=50, blank=True) zip_code = models.CharField( max_length=20, blank=True) phone_number = PhoneNumberField( blank=True) cell_number = PhoneNumberField( blank=True) skype = models.CharField( max_length=255, blank=True) linkedin = models.CharField( max_length=255, blank=True) twitter = models.CharField( max_length=255, blank=True) instagram = models.CharField( max_length=255, blank=True) facebook = models.CharField( max_length=255, blank=True) website = models.CharField( max_length=255, blank=True) timezone = TimeZoneField() birthdate = models.DateField( null=True) is_birthdate_hidden = models.BooleanField( default=False) comment = models.TextField( blank=True) bucket_default_job = models.CharField( max_length=255, blank=True) notifications = HStoreField( null=True) # so authentication happens by email instead of username # and username becomes sort of nick USERNAME_FIELD = 'email' # Make sure to exclude email from required fields if authentication # is done by email REQUIRED_FIELDS = ['username'] def __str__(self): return self.username class Meta: verbose_name = 'Employee' verbose_name_plural = 'Employees'

VIM shows a lot of bad tags (blank, defaults, editable etc) which is method arguments (field definition)

I'm using TagBar plugin: <a href="https://github.com/majutsushi/tagbar" rel="nofollow">https://github.com/majutsushi/tagbar</a>

<h3>Question</h3>

And it seems the problem is in ctags, how should I configure ctags so that it only outputs class attributes and not their definition params?

Answer1:

Use ctags from <a href="https://github.com/universal-ctags/ctags" rel="nofollow">universal-ctags</a>, it has resolved <a href="https://github.com/universal-ctags/ctags/issues/750" rel="nofollow">this issue</a>, and many other fixes.

a tag which universal-ctags generated:

branch tagbar_bug.py /^ branch = models.ForeignKey($/;" v class:Employee

Recommend

  • auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse ac
  • Django. How to add an extra field in User model and have it displayed in the admin interface
  • Newly added fields not showing in Profile Edit form in Django Oscar?
  • My 'Explicit Wait' doesn't work but 'Implicit Wait' Works?
  • What is better way to delete file with condition
  • how to enable Wi-Fi and search for networks on windows phone emulator
  • Check if a program exists in bash
  • Fiware response 503 - Service unavailable
  • Automapper Enum Description Attribute
  • Shell Function string variables result blank after While loop and case?
  • Pandas - Counting quantity of commas in character field
  • BASH: Ctrl+C during input breaks current terminal
  • why does bash tell me that the command if is not found when I run the following code?
  • Git cherry pick those commits that contain a keyword (tracking id)
  • Delete multiple lines - from “patternA” match, through second occurrence of “patternB”
  • Apple Reachability Notifications for Network OR Wi-Fi
  • Move an object (element) one step up with Javascript
  • Using Select and where statement in Criteria
  • C#, “Object reference not set to an instance of an object.” error
  • Getting data from database using HQL
  • How to merge two Request in Laravel
  • Laravel lmutator $this->attributes return 'Undefined index: id'
  • CSS Grid, position absolute an element in a css grid item: IMPOSSIBLE
  • how to get data attributes of dynamically generated element
  • C# fibonacci function returning errors
  • ListItem.Attributes.Add not working
  • How to write order and limit within cakephp joins array
  • How to change the font size of a single index for UISegmentedControl?
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Redux, normalised entities and lodash merge
  • how does django model after text[] in postgresql [duplicate]
  • Turn off referential integrity in Derby? is it possible?
  • Authorize attributes not working in MVC 4
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF